CouchbaseLite and CouchbaseLiteListener as frameworks with module support

11 views
Skip to first unread message

Brendan Duddridge

unread,
Aug 17, 2018, 1:34:15 PM8/17/18
to Couchbase Mobile
Hi,

I'm trying to utilize CBL 1.4.2 in a Swift app extension, so I need to build the dynamic framework version of CBL. 

That seems to be ok when I build the iOS Framework - Carthage version (built right from within Xcode, not actually using Carthage).

But when I do that and try to compile my app which also includes the CBL Listener framework, I get a bunch of compile errors referencing symbols in CBL Listener that aren't available for the arm64 architecture:

Undefined symbols for architecture arm64:

  "__mdictof", referenced from:

      -[CBL_Router queries] in CouchbaseLiteListener(CBL_Router.o)

      -[CBLDatabase(REST) updateAttachment:body:type:encoding:ofDocID:revID:source:status:error:] in CouchbaseLiteListener(CBLDatabase+REST.o)

      -[CBL_Router(Handlers) do_POST_revs_diff:] in CouchbaseLiteListener(CBL_Router+Handlers.o)

  "__castIf", referenced from:

      -[CBL_Router bodyAsDictionary] in CouchbaseLiteListener(CBL_Router.o)

      -[CBLView(REST) compileFromDesignDoc] in CouchbaseLiteListener(CBLView+REST.o)

      -[CBLView(REST) compileFromProperties:language:] in CouchbaseLiteListener(CBLView+REST.o)

      -[CBLDatabase(REST) getDesignDocFunction:key:language:] in CouchbaseLiteListener(CBLDatabase+REST.o)

      -[CBLDatabase(REST) compileFilterNamed:status:] in CouchbaseLiteListener(CBLDatabase+REST.o)

      -[CBL_Router(Handlers) do_POST_facebook_token] in CouchbaseLiteListener(CBL_Router+Handlers.o)

      -[CBL_Router(Handlers) do_POST_bulk_docs:] in CouchbaseLiteListener(CBL_Router+Handlers.o)

      ...

  "_$regex", referenced from:

      -[CBL_Router processRequestRanges] in CouchbaseLiteListener(CBL_Router.o)

  "__dictof", referenced from:

      -[CBLResponse setInternalStatus:] in CouchbaseLiteListener(CBL_Router.o)

      -[CBLResponse setMultipartBody:type:] in CouchbaseLiteListener(CBL_Router.o)

      -[CBLDatabase(REST) updateAttachment:body:type:encoding:ofDocID:revID:source:status:error:] in CouchbaseLiteListener(CBLDatabase+REST.o)

      -[CBL_Router(Handlers) do_POST_persona_assertion] in CouchbaseLiteListener(CBL_Router+Handlers.o)

      -[CBL_Router(Handlers) do_POST_facebook_token] in CouchbaseLiteListener(CBL_Router+Handlers.o)

      -[CBL_Router(Handlers) do_GET_uuids] in CouchbaseLiteListener(CBL_Router+Handlers.o)

      -[CBL_Router(Handlers) do_GET_session] in CouchbaseLiteListener(CBL_Router+Handlers.o)

      ...

  "__AssertFailed", referenced from:

      -[CBL_Router route] in CouchbaseLiteListener(CBL_Router.o)

      -[CBL_Router run] in CouchbaseLiteListener(CBL_Router.o)

      _CBLStartServer in CouchbaseLiteListener(CBL_URLProtocol.o)

      -[CBLDatabase(REST) attachmentForRevision:named:status:] in CouchbaseLiteListener(CBLDatabase+REST.o)

      ___42-[CBL_Router(Handlers) do_POST_bulk_docs:]_block_invoke in CouchbaseLiteListener(CBL_Router+Handlers.o)

  "_$equal", referenced from:

      -[CBLHTTPConnection supportsMethod:atPath:] in CouchbaseLiteListener(CBLHTTPConnection.o)

      -[CBLHTTPConnection expectsRequestBodyFromMethod:atPath:] in CouchbaseLiteListener(CBLHTTPConnection.o)

      -[CBL_Router boolQuery:] in CouchbaseLiteListener(CBL_Router.o)

      -[CBL_Router cacheWithEtag:] in CouchbaseLiteListener(CBL_Router.o)

      -[CBL_Router route] in CouchbaseLiteListener(CBL_Router.o)

      -[CBL_Router processRequestRanges] in CouchbaseLiteListener(CBL_Router.o)

      -[CBL_Router sendResponseHeaders] in CouchbaseLiteListener(CBL_Router.o)

      ...

ld: symbol(s) not found for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)





Is this because I'm using the dynamic CBL framework and the static CBL Listener framework together? 


Is there a way to compile the CBL Listener as a dynamic framework?


When I type 'file CouchbaseLite', I get the following:



CouchbaseLite: Mach-O universal binary with 2 architectures: [arm_v7:Mach-O dynamically linked shared library arm_v7] [arm64]

CouchbaseLite (for architecture armv7): Mach-O dynamically linked shared library arm_v7

CouchbaseLite (for architecture arm64): Mach-O 64-bit dynamically linked shared library arm64



But when I type 'file CouchbaseLiteListener', I get the following:

CouchbaseLiteListener: Mach-O universal binary with 4 architectures: [arm_v7:current ar archive] [arm64]
CouchbaseLiteListener (for architecture armv7): current ar archive
CouchbaseLiteListener (for architecture i386): current ar archive
CouchbaseLiteListener (for architecture x86_64): current ar archive
CouchbaseLiteListener (for architecture arm64): current ar archive


So it would seem that the two frameworks are built differently.


Can you think of a reason why CouchbaseLiteListener is not able to see those symbols?


I think this is the only thing preventing me from successfully compiling my iOS app extension.


Thanks,


Brendan




Jens Alfke

unread,
Aug 17, 2018, 2:16:52 PM8/17/18
to Couchbase Mobile


> On Aug 17, 2018, at 10:34 AM, Brendan Duddridge <bren...@gmail.com> wrote:
>
> Is this because I'm using the dynamic CBL framework and the static CBL Listener framework together?

Probably, yes. The static listener library is using internal utility functions from CBL that aren't exported from the dynamic lib.

> Is there a way to compile the CBL Listener as a dynamic framework?

I'm pretty sure there is. There may not be a premade scheme for it, but look in the list of targets in the Xcode project.

—Jens
Privacy Policy<https://www.couchbase.com/privacy-policy> | Update Marketing Preferences<https://info.couchbase.com/unsubscribe-or-manage-preferences>

Brendan Duddridge

unread,
Aug 17, 2018, 3:52:59 PM8/17/18
to Couchbase Mobile
Thanks for your quick response Jens.

There isn't a CouchbaseLite Listener Framework target. But I won't be using the listener from within my extension, so I guess I don't need it to be a dynamic framework. Only CouchbaseLite framework will be used from within the app extension.

But perhaps if I could just modify the CBL dynamic framework to export the internal utility functions so that CouchbaseLiteListener framework could access them, then it would compile?

Is it just a matter of adding the CollectionUtils.h header file from MyUtilities to the CBL iOS Framework's Headers Build Phase?

I just tried that and it didn't seem to work. When I compile I get the same issue.

I did try to add CollectionUtils.m to the Compile Sources build phase, but then I just got errors that there were duplicate symbols. So I'm sure it's compiling those functions into the app, but as you say, not being exposed by the dynamic framework.

I feel like I'm so close to getting it...

Thanks,

Brendan

Brendan Duddridge

unread,
Aug 17, 2018, 4:58:40 PM8/17/18
to Couchbase Mobile
I got it compiling now by adding the following directly to the Listener IOS Library target:

MyRegexUtils.m
ExceptionUtils.m
CollectionUtils.m
Test.m
Test_Assertions.m

And now it runs and now I can move on.

Thanks!

Brendan
Reply all
Reply to author
Forward
0 new messages