Error linking Couchbase Lite Listener framework for iOS


#1

I am trying to use the Couchbase Lite REST API but once I added the Couchbase Lite Listener framework to my project it will no longer build. I get the following error:

ld: warning: directory not found for option '-F/Users/work/Documents/FacebookSDK'
Undefined symbols for architecture x86_64:
  "_CBLGetHostName", referenced from:
      -[CBLListener URL] in CouchbaseLiteListener(libCouchbaseLiteListener.a-x86_64-master.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I’m really new to iOS development and have only worked on existing projects before, so if I’m missing some obvious build step please let me know. I added the Couchbase Lite Listener framework to my project by dragging the .framework file from a Finder window to my project. I also dragged it to the bottom of the Link Binary With Libraries list, in case the order mattered and Couchbase Lite had to be linked first.

Some sort of getting started guide for the Couchbase Lite REST API would be a great addition to the documentation. The API itself is documented, but it doesn’t say anywhere how to actually connect to the couchbase lite local server. The closest thing to documentation is that the API examples say they are contacting http://localhost:59840, so I tried that assuming the port number was hardcoded in couchbase lite somewhere but it failed to connect. I figured out to use the interalUrl by looking through the Couchbase Lite framework header files and guessed that’s what I should use as my base url to contact the REST API. I found out I needed to have the Couchbase Lite Listener framework in my project by googling the errors I got after trying to connect to that url.


#2

You’ve added CouchbaseLite.framework as well as the listener, right? In that case I don’t know why you’d be getting this error … which version are you using?

Some sort of getting started guide for the Couchbase Lite REST API would be a great addition to the documentation.

I think this hasn’t been a priority because nearly everyone using the REST API does it via PhoneGap (aka Cordova), so they just let the Couchbase Lite PhoneGap plugin do the initialization for them. Is your app different enough that you can’t use PhoneGap?


#3

I’m using couchbase lite v1.0.4 and couchbase lite listener v1.0.4. We didn’t originally have couchbase lite listener included so I just downloaded the couchbase lite ios v1.0.4 package from the couchbase downloads page and included it. I don’t know where we got the original couchbase lite framework, so I tried removing our original version and installing the version I got from the downloads page and it worked. I guess we had some weird version in our project.

I just want to use the REST API to make a PUT request of an existing document so that it accepts the existing rev field and doesn’t try to create a new revision. I’m trying to implement the solution you proposed to me in a different question I asked (How do I retrieve a set of documents by id from the server in couchbase lite?), this is what you said to do:
"I don’t think the public native API exposes the method to insert an existing revision, because normally it’s only needed by the replicator. However, it is exposed in the Couchbase Lite REST API; you PUT the revision as usual but set the URL query param ?new_edits=false."
Do I need to install PhoneGap to do that? It wouldn’t be overkill or anything? Since I only want to use the REST API to make this one PUT request. If PhoneGap is required to use the Couchbase Lite REST API it would be useful to have that requirement at the head of the API documentation. It’s just kind of confusing right now on how or when you would use the Couchbase Lite REST API, and how it is different from the Native API.


#4

Sorry, I forgot about my earlier reply to you! Yes, using the listener is a reasonable thing to do here, since the alternative is calling into fragile private APIs.

It sounds like you originally added an older version of Couchbase Lite to your project, which didn’t contain the internal symbol the newer listener needed. The two frameworks are tightly coupled and always need to be the same version.