Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Soulstorm

macrumors 68000
Original poster
Feb 1, 2005
1,887
1
This new way that XCode 4.0 handles dependencies frustrates me.

What I want to do is to have a project that has as a dependency a framework. And I want the resulting .framework file to be copied into the actual executable. In Xcode 3 this was a simple procedure, but now, I can't do it with XCode 4.

I create a new workspace. I add the Application Project. I then drag and drop the Framework's project file underneath the Application Project inside the workflow navigator. I select the Application Project's target, and I add as a dependency the framework. I also Link it with this library.

Now, if I build the Application project it will run just fine, but the .framework file is not included in the application bundle which means that when it is being transferred into another location it will not open!

I remember in XCode 3 that there was a copy files build phase that allowed copying the frameworks with the executable. In XCode 4, I can't select the framework file to add it into the copy files build phase!

Please help me, this is an important problem for me.
 
I took me a while to figure this one too.

You need to drag the .framework from the Project navigator to the Copy Files build phase, instead of trying to add it to the Copy Files build phase directly using the + button.
 
That will indeed copy the framework BUT it won't link only the copied framework.

When I do this, the actual executable is build inside the same folder "Debug" with my framework in the same folder. The framework exists also inside the application bundle! If I delete any of the two, either the one that is inside the application bundle, or the one that is in the same folder as the application bundle, the application crashes complaining it can't find the framework.

I suspect it has something to do with my build configuration but I haven't located the problem, yet.

Please can you point me in the right direction?

EDIT: Strangest thing: If I run the app using the Finder and not XCode, the application crashes again saying that it can't find the library file. Running it using XCode seems to work fine. What does this mean?
 
Last edited:
That will indeed copy the framework BUT it won't link only the copied framework.

I had to add a run script build phase with the following:

Code:
/usr/bin/install_name_tool \
    -change \
    /Library/Frameworks/MyLib.framework/Versions/A/MyLib \
    "@executable_path/../Frameworks/MyLib.framework/Versions/A/MyLib" \
    "$CONFIGURATION_BUILD_DIR/$EXECUTABLE_PATH"

But I'm thinking that I don't know how to do this. This seems wrong. There's no target dependency between MyLibTest app and MyLib framework. MyLibTest is linked explicitly to the debug version of MyLib, even we MyLibTest is build for release. This all seems too low level. I feel that I'm doing things XCode should be doing for me.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.