Blog

Many From One, Again

May 25, 2012

Several months ago I wrote about some tricks I was using to build many targets from one code base. The rubber is meeting the road on that project as we get closer to being ready to submit to Apple, and what I thought then was the solution is turning out not to be so.

In the original post, I basically suggested that this simple command lined would do the trick:

% xcodebuild -alltargets -configuration Distribution

And in fact, it does, to the extent that all the targets are built. The problem? This is a build, not an archive operation. So lots of bianries are created, but nowhere useful, and certainly not in the Organizer. (Anyone know any tricks to go from this point to an archive in the Organizer?)

It turns out that xcodebuild has an archive build action, but that only works if you also specify a scheme, for example:

% xcodebuild -scheme MyApp archive # No dash on 'archive', the build action

This has the nice result that the Archive action is taken for the specified scheme, and the resulting package can be found in the Organizer. But there are 2 problems with this (at least in my setup):

  1. My Archive configuration is set to Ad Hoc, not Distribution, and
  2. I am building each target manually.

In that old post, someone commented that I might be able to have Xcode do all the work (never using the command line) if I created a “Build All” scheme, and added all my targets to it. I thought that would do the trick of building and archiving each target. But it doesn’t work that way; it builds all the targets into a single package, archives that single package, and puts that into the Organizer. Not useful at all, at least not for then being able to submit to the App Store.

In another post, I wrote about something I called The Distro Scheme, a scheme whose Archive action’s configuration was Distribution. For a project where you have one target, duplicating that target as “Distro: MyApp” (or whatever) and setting it up as described works nicely. But for many targets? I am not so sure…

Be that as it may, I may have to create a “Distro: xxx” scheme for each target in my project, and then write a shell script that uses the output from “xcodebuild -list” to pluck out the Distro schemes, and build those schemes with the “archive” build action. It could work!

The drudgery of duplicating and editing schemes awaits… I’ll post the script somewhere when it’s done.

If you have any thoughts on this topic, please chime in!