macosframeworksxcode5dyld

OS X Framework Library not loaded: 'Image not found'


I am trying to create a basic OS X Framework, right now I just have a test framework created: TestMacFramework.framework and I'm trying to import it into a brand new OS X Application project.

I have built the .framework file and imported it into the new project, The framework appears to link okay, and I can reference the public header file I added to the framework build phases section.

However, when I try to run the container Application I get the following Error:

dyld: Library not loaded: /Library/Frameworks/TestMacFramework.framework/Versions/A/TestMacFramework
  Referenced from: /Users/samharman/Library/Developer/Xcode/DerivedData/TestMacContainer-dzabuelobzfknafuhmgooqhqrgzl/Build/Products/Debug/TestMacContainer.app/Contents/MacOS/TestMacContainer
  Reason: image not found

After a bit of googling I realised I needed to add a Copy Files section to my container application build phases, so I have done this and set it up like so...

enter image description here

However, I am still getting the runtime error. I'm obviously doing something wrong here, but the Apple developer library resource for this references Xcode 2, so isn't very helpful!

What have I missed?

UPDATE:

I can see in the build log that my TestMacFramework.framework is being copied into the .app contents/frameworks directory, but it isn't being installed to the Library/Frameworks directory on the HD

enter image description here

UPDATE 2:

The build links correctly if I manually copy the TestMacFramework.framework into the Library/Frameworks directory


Solution

  • [Xcode 11+]

    The only thing to do is to add the framework to the General->Frameworks, Libraries And Embedded Content section in the General tab of your app target.

    Make sure you select the 'Embed & Sign' option.

    enter image description here

    [Xcode v6 -> Xcode v10]

    The only thing to do is to add the framework to the Embedded binaries section in the General tab of your app target.

    Screenshot from Xcode