I have an Xcode project with many targets. Six of them are aggregates which build final release products (static libraries, frameworks) using Run Scripts under Build Phases. I can build them each individually fine, but I can't find any way to hit "one button" to build them all.
Approach #1
First I tried using -alltargets from the command line, like so:
xcodebuild -project MyProject.xcodeproj -alltargets
With that I get errors on my test targets, claiming that they aren't built for testing. I don't know what that means because they normally "test" correctly. Something is different when attempted this way. But technically it's including targets I'm not interested in. I wouldn't mind much if it worked.
Approach #2
Next I tried making an aggregate which had a run script that individually built each aggregate target, like so:
xcodebuild -project MyProject.xcodeproj -target FirstAggregateTarget
xcodebuild -project MyProject.xcodeproj -target SecondAggregateTarget
xcodebuild -project MyProject.xcodeproj -target ThirdAggregateTarget
xcodebuild -project MyProject.xcodeproj -target FourthAggregateTarget
xcodebuild -project MyProject.xcodeproj -target FifthAggregateTarget
xcodebuild -project MyProject.xcodeproj -target SixthAggregateTarget
It doesn't get any errors from Xcode's point of view, but several of the aggregates just don't build properly. Somehow the run scripts in the individual aggregates were influenced by the top-level aggregate, I guess.
Approach #3
Next I then tried making a new "RELEASE_PRODUCTS" scheme that in the build section had the six aggregates listed. With that I got errors like this:
There were also other obscure errors about build products not being found where they were expected to be.
Approach #4
Next I created a script that I run completely outside of Xcode, like so:
#!/bin/bash
# Builds all release products
xcodebuild -project MyProject.xcodeproj -target FirstAggregateTarget
xcodebuild -project MyProject.xcodeproj -target SecondAggregateTarget
xcodebuild -project MyProject.xcodeproj -target ThirdAggregateTarget
xcodebuild -project MyProject.xcodeproj -target FourthAggregateTarget
xcodebuild -project MyProject.xcodeproj -target FifthAggregateTarget
xcodebuild -project MyProject.xcodeproj -target SixthAggregateTarget
That seems to be the only thing that works. But I wish I could get this to work from within Xcode, preferably as something I could hit from the command line if I wanted to, because then I wouldn't have to leave the IDE and it could report to be success or fail.