How to tell if Xcode is doing a "build and archive" in a script?
I have a script that does some preprocessing before the actual build in Xcode. Is there a way to tell when Xcode is doing a "Build and Archive"? I want to do an "svn commit" as part of the archive step. I dumped the environment variables that are there during a build, but they look the same for an archive as a normal build.
Anything else that can be checked to tell if it is building an archive?
Any other way to automatically do a com开发者_如何学运维mit before it builds the archive? I don't want to do a commit for every build as this makes the svn tree harder to navigate IMO.
I'm using Xcode 3.2.5.
Thanks! Norm
I wanted to avoid the command line build and archive since I read that it does not build a .ipa file with the provisioning profile embedded in it. Using that makes sending it out to testers much easier.
What I did was the following:
I have 4 configurations. Debug, Release, Ad Hoc Release, and App Store Release.
I use Debug and Release to build without doing a commit. I use the Ad Hoc when I want to send to beta testers, and the App Store for final testing and App Store submittal.
Here is the code that I added to my pre-build script.
# Get the version number from the .plist file
VER_NUM=`cat "${SRCROOT}/${INFOPLIST_FILE}" | grep -A 1 CFBundleVersion | grep string | sed 's/]*>//g' | sed 's/^[ ]*//'`
# Check build type to see if svn commit should be done
if [ "${BUILD_STYLE}" == "App Store Distribution" ]
then
SVN_COMMIT=yes
fi
if [ "${BUILD_STYLE}" == "Ad Hoc Distribution" ]
then
SVN_COMMIT=yes
fi
if [ "${SVN_COMMIT}" == "yes" ]
then
echo "Commiting the project to SVN"
BUILD_TIME=`date`
svn commit -m "\"Version ${VER_NUM} for ${BUILD_STYLE} ${BUILD_TIME}\""
fi
This was my quick and dirty answer to the problem. There has to be a more elegant solution, but this will work for now. If Apple would just add an environment variable to show that it is an archive build that would solve it.
I recommend you to get daily build system with independent script from Xcode GUI. This will make just svn commit
trigger Build and Archive and distribution. You can run Build and Archive with xcrun
command like described in here:
Xcode "Build and Archive" from command line
精彩评论