Mac App / 64 Bit Sample Project

134 views
Skip to first unread message

Nate Smith

unread,
May 22, 2014, 6:40:33 PM5/22/14
to mobile-c...@googlegroups.com
For the life of me I cannot get the 64 bit version of the 3.1 beta to compile with xcode 5.1.  I keep getting this lovely error:
Undefined symbols for architecture x86_64:
 
"_NSFileProtectionCompleteUnlessOpen", referenced from:
     
-[CBL_BlobStoreWriter initWithStore:] in CouchbaseLite(CBL_BlobStore.o)
 
"_NSFileProtectionKey", referenced from:
     
-[CBL_BlobStoreWriter initWithStore:] in CouchbaseLite(CBL_BlobStore.o)
 
"_OBJC_CLASS_$_UIApplication", referenced from:
      objc
-class-ref in CouchbaseLite(CBL_Replicator+Backgrounding.o)
 
"_OBJC_CLASS_$_UITableViewCell", referenced from:
      objc
-class-ref in CouchbaseLite(CBLUITableSource.o)
 
"_UIApplicationDidEnterBackgroundNotification", referenced from:
     
-[CBLDatabase initWithPath:name:manager:readOnly:] in CouchbaseLite(CBLDatabase.o)
     
-[CBL_Replicator(Backgrounding) setupBackgrounding] in CouchbaseLite(CBL_Replicator+Backgrounding.o)
     
-[CBL_Replicator(Backgrounding) endBackgrounding] in CouchbaseLite(CBL_Replicator+Backgrounding.o)
 
"_UIApplicationWillEnterForegroundNotification", referenced from:
     
-[CBL_Replicator(Backgrounding) setupBackgrounding] in CouchbaseLite(CBL_Replicator+Backgrounding.o)
     
-[CBL_Replicator(Backgrounding) endBackgrounding] in CouchbaseLite(CBL_Replicator+Backgrounding.o)
 
"_UIApplicationWillTerminateNotification", referenced from:
     
-[CBLDatabase initWithPath:name:manager:readOnly:] in CouchbaseLite(CBLDatabase.o)
 
"_UIBackgroundTaskInvalid", referenced from:
     
-[CBL_Replicator(Backgrounding) setupBackgrounding] in CouchbaseLite(CBL_Replicator+Backgrounding.o)
     
-[CBL_Replicator(Backgrounding) endBGTask] in CouchbaseLite(CBL_Replicator+Backgrounding.o)
     
-[CBL_Replicator(Backgrounding) okToEndBackgrounding] in CouchbaseLite(CBL_Replicator+Backgrounding.o)
      ___50
-[CBL_Replicator(Backgrounding) appBackgrounding:]_block_invoke in CouchbaseLite(CBL_Replicator+Backgrounding.o)
      ___50
-[CBL_Replicator(Backgrounding) appForegrounding:]_block_invoke in CouchbaseLite(CBL_Replicator+Backgrounding.o)
ld
: symbol(s) not found for architecture x86_64
clang
: error: linker command failed with exit code 1 (use -v to see invocation)

So I was wondering if anyone has succesfully created a 64 bit project?  If so, would you be willing to post it somewhere or share your experience getting things setup? 

Heck, I'd even be willing to pay someone for an hour of their time to walk me through getting this working properly.  Also, if that's not appropriate or frowned upon when posting to the group, forget I said anything about it.

Thanks for you help in advance.


Jens Alfke

unread,
May 22, 2014, 7:31:21 PM5/22/14
to mobile-c...@googlegroups.com

On May 22, 2014, at 3:40 PM, Nate Smith <nates...@gmail.com> wrote:

For the life of me I cannot get the 64 bit version of the 3.1 beta to compile with xcode 5.1.  I keep getting this lovely error:

What exactly are you trying to compile? The missing symbols are all from iOS, and your subject line says you’re building for Mac. So it sounds like you’re trying to build a Mac app using the iOS version of Couchbase Lite?

We don’t ship a pre-compiled Couchbase Lite library for Mac OS. (Maybe someday…) You’ll need to check out the repository from Github and build the Mac target to produce a framework.

Also, since 1.0 is out now you should work with that instead of betas.

—Jens

Nate Smith

unread,
May 23, 2014, 10:34:07 PM5/23/14
to mobile-c...@googlegroups.com

Okay, I cloned the source code like you said and changed my target to CBL Mac.  When I run products > archive I get this window:

I'm lost as to what to do from here.  The docs say "Then use the Organizer window's Archives tab to find the archive and the CouchbaseLite.framework it contains."  I don't get how to find the archive, there's only one line shown named CBL Mac.  Also Do I need to click Validate or Distribute and if so what then?

This is all new to me and I find it very confusing.  Do you have any more detailed documentation somewhere? 

Pascal

unread,
May 23, 2014, 11:37:53 PM5/23/14
to mobile-c...@googlegroups.com
Yes, you simply hit "Distribute", then choose "Save Built Products", choose where to save it and it will store the framework (in some subdirectories, just grab it out from there).

If you think you will update the framework from time to time, you can have a script build CouchbaseLite from command line and move the framework into place. Along these lines:

$ cd couchbase-lite-ios
$ xcodebuild -scheme "CBL Mac" -configuration "Release" -archivePath "current-build" archive
$ mv current-build.xcarchive/Products/Library/Frameworks/CouchbaseLite.framework ../

For example I have a build phase script that checks if "CouchbaseLite/CouchbaseLite.framewok" is in place, if it is not it executes these three lines (with the proper path at the end of command 3 of course). Then just drag the built framework into Xcode. When I want to update the framework I just delete the built product and it will be replaced by a fresh build next time I hit run.

Nate Smith

unread,
May 24, 2014, 5:25:57 PM5/24/14
to mobile-c...@googlegroups.com
Thank you @Pascal, that was an awesome answer.  I did what you said from the command line and it successfully built the framework.  I then drag it into my projects framework group folder, run the project and I get this error:

dyld: Library not loaded: @rpath/CouchbaseLite.framework/Versions/A/CouchbaseLite
 
Referenced from: /Users/nate/Library/Developer/Xcode/DerivedData/CBL-bdkrdsgxtmsootdrnldzujvvfgvy/Build/Products/Debug/CBL.app/Contents/MacOS/CBL
 
Reason: image not found

I'm not really sure what this error means.

Jens Alfke

unread,
May 24, 2014, 6:17:25 PM5/24/14
to mobile-c...@googlegroups.com

On May 23, 2014, at 7:34 PM, Nate Smith <nates...@gmail.com> wrote:

I'm lost as to what to do from here.  The docs say "Then use the Organizer window's Archives tab to find the archive and theCouchbaseLite.framework it contains."  I don't get how to find the archive, there's only one line shown named CBL Mac.

Right-click it and choose “Show In Finder”. Then in the Finder window, right-click the archive and choose “Show Package Contents”. The framework is in the folder that opens, I think down inside the “Products” subfolder.

No, I don’t understand why Xcode makes this so awkward. :-p

(Sorry I didn’t spell this out in the wiki page. It’s the same runaround you use whenever you do an Archive build of anything, so I assumed people would already be familiar with it.)

—Jens

Nate Smith

unread,
May 24, 2014, 6:48:05 PM5/24/14
to mobile-c...@googlegroups.com
Ya, that's the folder I drug into my project, then when I run it I get the error:

dyld: Library not loaded: @rpath/CouchbaseLite.framework/Versions/A/CouchbaseLite
 
Referenced from: /Users/nate/Library/Developer/Xcode/DerivedData/CBL-bdkrdsgxtmsootdrnldzujvvfgvy/Build/Products/Debug/CBL.app/Contents/MacOS/CBL
 
Reason: image not found

Like it's missing some kind of library or something.  Inside the Couchbase.framework folder
(the one from the archive) I noticed everything is a symlink, is that correct?



Pascal

unread,
May 24, 2014, 10:45:00 PM5/24/14
to mobile-c...@googlegroups.com
Did you first drag the built framework someplace else (in the Finder) before adding it to Xcode? Put it at the top level of your project, maybe inside a CouchbaseLite folder you create yourself. Then drag it into the project from there.

Jens Alfke

unread,
May 24, 2014, 11:34:49 PM5/24/14
to mobile-c...@googlegroups.com

On May 24, 2014, at 3:48 PM, Nate Smith <nates...@gmail.com> wrote:

Ya, that's the folder I drug into my project, then when I run it I get the error:

Did you follow all the steps? Adding a 3rd party framework to an app is unfortunately non-trivial. The runtime error you’re getting says that the loader can’t find the CBL framework when it tries to resolve the libraries your app binary links with, which implies the framework is missing or in the wrong place or your binary’s reference to where it should be is wrong. Make sure you followed these steps:

  1. For a Mac OS target, you'll need to make sure the framework is copied into your app's bundle:
    1. To to the "Build Settings" tab of your app target's settings.
    2. In the "Linker" section, edit "Runpath Search Paths" and add the path "@loader_path/../Frameworks".
    3. Now switch to to the "Build Phases" tab.
    4. Press the "Add Build Phase" button at the bottom of the window and create a new "Copy Files" phase.
    5. Set the phase's destination to "Frameworks".
    6. Press the "+" button below the phases' file list and select CouchbaseLite.framework to add it.


—Jens
Reply all
Reply to author
Forward
0 new messages