Sam
Sam

Reputation: 2875

How to link a stand-alone Swift OS X app to a private framework (also created in Swift)?

I get the following error when trying to embed a private framework into a Swift OS X app:

dyld: Library not loaded: @rpath/CustomCalcs.framework/Versions/A/CustomCalcs Referenced from: /Users/sam/Library/Developer/Xcode/DerivedData/TestFramework-ckcpduuqyfclssceomyzqbxgbjdi/Build/Products/Debug/TestFramework.app/Contents/MacOS/TestFramework Reason: image not found

I am trying to simulate the scenario where I am the receiver of a .framework file from a 3rd party and don't have access to the source code or Xcode project file (even though in my simple test of course I do)

Steps I have taken: 1. Add file to my target project making sure to copy it into the project 2. The Xcode syntax highlighting/completion then becomes aware of the classes within the framework - this is good 3. I add a "copy file" step in the Xcode "build phase". I have added it to "frameworks" 4. When examining the directory that the app runs from within DerivedData, I can find no framework directory and no .framework file 5. When I run the app the error above occurs

It would appear that I need to setup a step whereby the .framework file is copied into a deployment directory AND somehow the app knows to look in this location. How specifically do I go about doing this in Xcode?

Upvotes: 3

Views: 540

Answers (1)

Tokuriku
Tokuriku

Reputation: 1352

I may be wrong but is seems like a case of "Linked Frameworks and Libraries" vs "Embedded Binaries".

  1. Click on your project Workspace
  2. Select your project Target
  3. In the General tab, remove the Framework from "Linked Frameworks and Libraries"
  4. Add it to "Embedded Binaries"
  5. Build

It will be automatically added to the "Linked Frameworks and Libraries" also but you'll have it once instead of two times.

Upvotes: 1

Related Questions