Reputation: 48566
Are certain variables that were available to run scripts in Xcode 3 no longer available to pre-build script actions in Xcode 4?
The script
PLIST_FILE="$SRCROOT/$INFOPLIST_FILE"
echo "${PLIST_FILE}"
produces just "/" as output: neither SRCROOT nor INFOPLIST_FILE appear to be defined. Do these have new names in Xcode 4; is this a bug?
Upvotes: 1
Views: 3836
Reputation: 3806
In Edit Schema -> Build -> Pre-actions, make sure one of the target is selected for "Provide build settings from" (not none) option.
cp SOME_PATH/build.gradle "${SRCROOT}/build.gradle"
Upvotes: 0
Reputation: 61228
Update: Xcode 4.1 finally addresses this issue. A new popup in the script editor lets you choose the target on which Xcode bases the environment variables it makes available to your script (you can still choose "none" ... an option of questionable usefulness).
Old Post About 4.0 Follows
That's because, for whatever reason, Xcode environment variables are unavailable in pre- and post-action scripts in the current version.
Nobody has any idea why (or how they're useful without envvars).
Quick test - Add this in a script:
printenv ~/Desktop/EnvVars.txt
... then open up the text file and witness the disappointment. :-)
Upvotes: 13
Reputation: 977
"$SRCROOT/$INFOPLIST_FILE" work fine for me in Xcode 4.1 Build 4B110 on Mac OSX Lion.
Upvotes: 0