I’m building/archiving my Mac app for distribution from a command line call (below), with Xcode 4.3 installed. To be clear, I didn’t have a working solution for this problem earlier to Xcode 4.3, so advice for earlier Xcode releases could easily still be valid. Here’s the call:
/usr/bin/xcodebuild -project "ProjectPath/Project.pbxproj" -scheme "Project" -sdk macosx10.7 archive
This runs successfully, and it generates an .xcarchive file, located in my ~/Library/Developer/Xcode/Archives/<date> folder. What’s the proper way to get the path the the archive file generated? I’m looking for a way to get a path to the .app file contained therein, so I can distribute it.
I’ve looked at the MAN page for xcodebuild (and done copious searching online) and didn’t find any clues there.
Building on the answer provided here, I came up with a satisfactory multi-part solution. The key to it all, was to use the environment variables Xcode creates during the build.
First, I have a post-action on the Archive phase of my build scheme (pasted into the Xcode project’s UI). It calls a Python script I wrote (provided in the next section), passing it the names of the environment variables I want to pull out, and a path to a text file:
That script then writes them to a text file in
key = valuepairs:Then, finally, in my build script (also Python), I parse out those values and can get to the path of the archive, and the app bundle therein:
This was the way I solved it, and it should be pretty easily adaptable to other scripting environments. It makes sense with my constraints: I wanted to have as little code as possible in the project, I prefer Python scripting to Bash, and this script is easily reusable in other projects and for other purposes.