As written, this script is for iPhone OS only. Modifications are required for Mac OS X support (mostly removing the adhoc packaging) and to fix the SDK_NAME trigger.
This script is intended to be run during an Xcode build to archive your build's
dSYM bundles (needed for symbolicating crash logs received from iTunes Connect
or beta testers' feedback) and, for beta releases, to create an .ipa package to
send to your beta testers.
By default, the dSYM bundle will be copied to and the .ipa will be created in
${ARCHIVE_BASE}/${PROJECT_NAME}/${CONFIGURATION}/${ARCHIVE_DATE}/.
ARCHIVE_BASEis set at the top of the script and defaults to${HOME}/dSYMArchive/;PROJECT_NAMEandCONFIGURATIONare values provided by Xcode.ARCHIVE_DATEis the archive time inYYYYMMDD-hhmmssformat.
You may change ARCHIVE_BASE at the top of the script if ${HOME}/dsymArchive
is not to your liking. This location must be in a location accessible to
spotlight.
See a presentation I gave at TACOW in January 2010 for more information (slides 17-24). [Solving Little Problems][1]
Because an .ipa must be created from already-signed binaries, you will need
to create a new Target in your Xcode project.
- Right click on the Targets group, select Add > New Target. Select an Aggregate target from the Other group. Name it and save it.
- Bring up the Info inspector for your new aggregate target and add your executable(s) as direct dependencies for the target. Close the inspector.
- Right click on your aggregate target and select Add > New Build Phase > New
Run Script Build Phase. Set the Shell to
/bin/shand theScriptto a full path where you have placed this script. I keep it on a per-project basis in thescriptsfolder, so my path is${PROJECT_DIR}/scripts/dsym-archiver. You may optionally provide a base name for your.ipain the event that your project name and the eventual release name do not match (as happened in the project where I built this script).
This new aggregate target should now be made your default build target to obtain best results.
This script is fairly simple, but fairly verbose because it's using environment variables from Xcode to provide most of the magic involved.
-
If this build script is run and the
SDK_NAMEdoes not start withiphoneos, the script does nothing (and prints an error if you run the script outside of Xcode).case @${SDK_NAME} in @iphoneos*) archive_dsym_iphoneos "${1}" ;; @*) : ;; @) echo "Not running under Xcode." ;; esac -
If you're building an iPhone OS project, and you're running a build
CONFIGURATIONcontaining the termDistribution, it copies the dSYM debugging symbols from their target folder (DWARF_DSYM_FOLDER_PATH) to theARCHIVE_FOLDDER(described above).case ${CONFIGURATION} in *Distribution*) : ;; *) return ;; esac -
If step two has run, the script checks to see if you are using a
Beta(orbeta) buildCONFIGURATION. If you are, the.appfolders are copied to a temporary location; if there is aniTunesArtworkfile in the.appfolder, this is copied out as well. These are then zipped into an.ipaarchive and theARCHIVE_FOLDERis opened in iTunes.case ${CONFIGURATION} in *[Bb]eta*) prepare_adhoc_package "${1}" ;; *) return ;; esac
[1]: http://www.slideshare.net/halostatue/solving-little-things/17 Solving Little Problems Slide 17