Re: Wrong Frameworks Build Configuration Copied to App Pkg
Re: Wrong Frameworks Build Configuration Copied to App Pkg
- Subject: Re: Wrong Frameworks Build Configuration Copied to App Pkg
- From: Jerry Krinock <email@hidden>
- Date: Sun, 30 Mar 2008 22:33:52 -0700
I did some more experiments on this, using two little Demo projects.
Summary: Definitely Unexpected and Bad Behavior by Xcode's Copy Files
Build Phase. Use a Shell Script instead.
Conclusions:
• The problem is this: Regardless of the Build Configuration, when
copying private frameworks to an application's Contents/Frameworks in
a Copy Files Build Phase, Xcode always copies the Release version of
the private frameworks. This behavior is unexpected and has caused me
alot of grief...
• When running products from Xcode, it somehow loads the proper,
e.g. Debug, framework, instead of the one in its package. This clever
little patch makes the resulting problems more difficult to understand.
• The wrong (packaged) framework does run when running a non-
Release product by doubleclicking in the Finder, or after copying it
to another Mac. This bit me last week when I wanted to find a crash
by copying a ReleaseUnstripped configuration of my app on an old
Powerbook (PowerPC) running Panther. Instead, my test ran with the
Release build, which was, at the time, down-rev.
• If you clean the Release version of a framework and then do a non-
Release build of the app, during the Copy Files (to Frameworks) build
phase, pbxcp will fail with a source-directory-not-found error. This
has induced several episodes of hair-pulling as my clean-and-build-all-
configurations AppleScript failed unpredictably.
The solution is to copy your private frameworks to the product's
Contents/Frameworks by using a shell script, and to not use a Copy
Files Build Phase to Frameworks. Something like this should work:
cd $BUILT_PRODUCTS_DIR
rm -Rf $TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/
mkdir $TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/
cp -Rfp MyFramework1.framework $TARGET_BUILD_DIR/$PRODUCT_NAME.app/
Contents/Frameworks
cp -Rfp MyFramework2.framework $TARGET_BUILD_DIR/$PRODUCT_NAME.app/
Contents/Frameworks
cp -Rfp MyFramework3.framework $TARGET_BUILD_DIR/$PRODUCT_NAME.app/
Contents/Frameworks
(The reason for the rm is due to a stupid thing with cp. If the
framework already exists in the destination, cp will fail with two
errors of the form "cannot overwrite directory <...> with non-
directory <...>" when it attempts to overwrite the two symbolic links
to a directories, namely xxx.framework/Resources and xxx.framework/
Versions/Current. The -R option makes it not follow the link when
copying, but apparently it does follow the link when comparing file
types for overwriting.)
Disadvantage is that I have to remember to list my private frameworks
in the shell script, but that's cancelled out by the fact that I no
longer need to drag them into Copy Files Build Phase.
Does anyone know a better way to fix this?
Jerry
(I have a longer version of this message, probably too long to post,
which gives steps to reproduce the results, if anyone wants it.)
Part of Original Message: On 2008 Mar, 20, at 17:18, Jerry Krinock
wrote:
I have an app and some private frameworks, all in separate
projects. Each has three Build Configurations: Release,
ReleaseUnstripped, and Debug. I use a common Build Products folder
set in Xcode preferences.
In order to add a private framework to an app, following the
documentation [1], I drag from the framework's "Groups & Files" ►
Products ► AFramework.framework into the "Groups & Files" "Files"
tab of the app. (I'm using Condensed View.) The documentation [1]
also says that I should also drag this same product to the app's
"Copy to Frameworks" Build Phase, but Xcode does not accept that
drag. So, instead, I drag the image of it that I have previously
dropped; i.e. from the "Files" tab to the "Targets" tab. That drag
is accepted.
Now, according to [2], "If your framework and your main app are
using the same shared build folder, the Frameworks Search Path
implicitly searches the shared build folder, and that works on a per-
configuration basis."
I've often wondered if this really works and today I found that it
ain't. I cleaned both Release and ReleaseUnstripped products with
"Also Clean Dependencies". Then, I built ReleaseUnstripped. The
Build Transcript, and examination of the products, shows that it
correctly produced each framework in Builds/ReleaseUnstripped
(they're dependencies), but when it got to Copy Files it tried to
copy the frameworks from Builds/Release and found No Such File.
[1] Apple's Framework Programming Guide ► Creating a Framework ►
Embedding a Private Framework in Your Application Bundle.
http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html#/
/apple_ref/doc/uid/20002258-106880
[2] http://www.cocoabuilder.com/archive/message/xcode/2006/1/25/3324
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden