Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build ordering in Xcode scheme build targets

In order to build an installer for my program I added an 'installer' Xcode project/target which copies all the needed binaries to a temporary location and then runs the necessary logic to build the package.

The problem that I am having is I want to map this installer project directly dependent on a few other projects so that they are built (if needed) every time I try to build the installer project.

I added all targets to the installer's Build target list (in the schema) and they are ordered like this:

Project A
Project B
Project C
Installer (self)

However when I do a clean build I see see a build order (in the build log) like this:

Project C
Installer
Project A
Project B

I need to force a certain build ordering or else the files will not be available for use by the installer. Xcode lets you change the order of these items in the UI but the order doesn't seem to do anything. Is there no way to force the build order of dependencies?

like image 799
Locksleyu Avatar asked Apr 23 '12 18:04

Locksleyu


3 Answers

In Xcode 13, the manual order is now stated to be strongly recommended against and will get you a warning.

like image 79
Paul Bruneau Avatar answered Nov 08 '22 06:11

Paul Bruneau


Xcode lets you change the order of these items in the UI but the order doesn't seem to do anything.

In my case, this was happening when "Parallelize Build" was ticked in the Scheme "Build" tab.

After disabling that checkbox, Xcode always followed the order I chose for the targets.

It makes sense if you think about it: when "Parallelize Build" is enabled, all targets without dependency constraints between them will be built in parallel, which may result in their out-of-order completion.

On the other hand, if you wish their sequential order to be strictly followed, well.. that's exactly the contrary of parallel building, and hence you should disable that option.

like image 34
yfede Avatar answered Nov 08 '22 07:11

yfede


Make targets A, B, and C target dependencies for the installer target, which will ensure A, B, and C are built before the installer. Select your project file from the project navigator to open the project editor. Select the installer target from the list of targets. Click the Build Phases button at the top of the editor to show the target's build phases. Click the disclosure triangle next to the Target Dependencies build phase. Click the + button to add dependencies.

When you add the target dependencies, targets A, B, and C will be built before the installer. If you need A, B, and C to be built in a specific order, you will have to add more target dependencies.

like image 5
Swift Dev Journal Avatar answered Nov 08 '22 06:11

Swift Dev Journal