问题
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?
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/10285964/build-ordering-in-xcode-scheme-build-targets