Drux
Drux

Reputation: 12650

How flexible is order of build phases for Xcode targets?

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?

Upvotes: 11

Views: 4555

Answers (4)

n_b
n_b

Reputation: 1156

Ran into this problem with XCode 7.1.1 (maybe exists from XCode 7). I could not drag recently added Run Scripts to anywhere, found I could drag existing items to the bottom though. So, if my items were

A
B
C
D (New runscript)

and I wanted to put D below A, first drag B to the bottom

A
C
D
B

and then drag C to the bottom

A
D
B
C

Hope that helps someone.

Upvotes: 0

thetrutz
thetrutz

Reputation: 1545

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.

Upvotes: 4

LunaCodeGirl
LunaCodeGirl

Reputation: 5630

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).

Upvotes: 10

justin
justin

Reputation: 104698

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).

Upvotes: 7

Related Questions