Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How flexible is order of build phases for Xcode targets?

Tags:

xcode

xcode6.1

Is it possible to configure the Build Phases of a target in Xcode 6.1 such that a Copy Files phase can occur before the Compile Sources phase?

like image 459
Drux Avatar asked Dec 09 '14 17:12

Drux


People also ask

What build system does Xcode use?

The new building system introduced in Xcode 10 is written by Swift from scratch, and brings lots of improved performance and reliability.

What are build phases?

Build Phase means that part or parts of the Category 1 Property or Phase thereof on which HDV proposes to build, isbuilding or has built the Development (and as may be related to the relevant Demolition Phase).


3 Answers

As far as I can tell there is no way to reorder items using the GUI in Xcode. You can do it by editing the project.pbxproj file though.

If you open that file up in some text editor (not Xcode) and do a search for something like

Build configuration list for PBXNativeTarget

You'll find a section like this

/* Begin PBXNativeTarget section */
    9BDEC0D019881B9400AE439B /* MyProject */ = {
        isa = PBXNativeTarget;
        buildConfigurationList = 9BDEC0F019881B9400AE439B /* Build configuration list for PBXNativeTarget "MyProject" */;
        buildPhases = (
            6111D3671B56D2BB00DD7431 /* Show TODOs and FIXMEs as Warnings */,
            BAEE6F558B6BDB326F5B8D1F /* Check Pods Manifest.lock */,
            9BDEC0CD19881B9400AE439B /* Sources */,
            9BDEC0CE19881B9400AE439B /* Frameworks */,
            4C47C03A1ABD4DFE00D317B5 /* Copy baked database to bundle sqlite */,
            9BDEC0CF19881B9400AE439B /* Resources */,
            CDF5E3A80B5FDFCEA41B67FD /* Embed Pods Frameworks */,
            CF995761C5EAA8D1AAEBA463 /* Copy Pods Resources */,
        );
        buildRules = (
        );
        dependencies = (
            9B832FED19B76A45006D3347 /* PBXTargetDependency */,
        );
        name = MyProject;
        productName = MyProject;
        productReference = 9BDEC0D119881B9400AE439B /* MyProject.app */;
        productType = "com.apple.product-type.application";
    };

You can change the order of operations in the buildPhases list.

See how the first thing in my list is 6111D3671B56D2BB00DD7431 /* Show TODOs and FIXMEs as Warnings */,? That is a custom build phase script I added using the GUI and then moved that line up to be the first using Atom. Reopened the GUI and it was the second build phase after "Target Dependencies" (as was mentioned in the other answer).

like image 145
LunaCodeGirl Avatar answered Sep 28 '22 02:09

LunaCodeGirl


Yes.

For existing phases such as "Copy" and "Compile" in your example:

  • View the Build Phases by selecting the Build Phases tab in the desired project's target
  • Then reorder phases (or elements of each phase) by dragging them using your mouse

Note: The "Target Dependencies" phase may not be reordered (at the time of this writing).

like image 34
justin Avatar answered Sep 27 '22 02:09

justin


In Xcode you can reorder the Build Phases in the GUI (XCode 6.4 and 7.1 beta), but sometimes the UI is somehow blocked. Try the following steps in order to unblock the UI:

  1. click on Build Rules,
  2. click on Build Phases,
  3. move the desired phase one step at a time.
like image 43
thetrutz Avatar answered Sep 30 '22 02:09

thetrutz