Date: 17 April 2007 11:38:50 AM
Subject: Including Private Frameworks
Hi guys,
I'm having a problem including a private framework in my app bundle. The private framework contains some code that we will be using in a bunch of apps, and as such I want it to remain a separate project and not another target of the app, as is suggested by the Apple doco[1]. I don't particularly want to follow the "Using Separate Xcode Projects For Each Target" section as I want the project to use a copy of the built framework installed on the development machine, rather than refer to the .xcodeproj, partly because you need to change the build products directory of both projects to point at the same place (?!)
Anyway, it's a pretty simple ask: Link against a custom framework (installed on the machine or in the project folder) and copy it into the application bundle. I can't find anywhere where this method is clearly covered in the documentation.
What I've done is this:
1) Set the "Installation Directory" property of the Framework's target to "@executable_path/../Frameworks" - this didn't really seem relevant but I noticed it changes what the output of otool says, so I tried it (tried it without as well)
2) Built framework
3) Installed framework to /Library/Frameworks
4) Added framework at the installed location to my project
5) Added a Copy Files build phase to copy the framework into the app bundle's Frameworks folder
Building with the Debug build configuration seems to work ok - the framework is copied to the right location. The application launches and fails with this error:
dyld: Library not loaded: /Users/loukas/Library/Frameworks/AeroPlugins.framework/Versions/A/AeroPlugins
Referenced from: /Users/loukas/Desktop/Plotter Control/build/Debug/Plotter Control.app/Contents/MacOS/Plotter Control
Reason: image not found
Inspecting the executable with otool -L shows the following:
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 11.0.0)
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
/Users/loukas/Library/Frameworks/AeroPlugins.framework/Versions/A/AeroPlugins (compatibility version 1.0.0, current version 1.0.0)
/System/Library/PrivateFrameworks/ZeroLink.framework/Versions/A/ZeroLink (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.3)
Now I have no idea where that /Users/loukas.. reference comes from because that's not where the framework is installed. If I use install_name_tool to change the reference to "@executable_path/../Frameworks/AeroPlugins.framework/Versions/A/AeroPlugins" all is well and the app launches successfully (well technically it doesn't because it tries to load two plugin modules that also have the same issue, but it gets past that stage of launching and doesn't complain until it tries to load the plugins). This prompted me to try changing the "Installation Directory" property of the main app's target to "@executable_path/../Frameworks", which doesn't really make a lot of sense, and that didn't have any effect.
Can anyone shed some light on the correct way to go about this in xcode?
Thanks,
Loukas