How To Configure Xcode Default, Workspace, Project Build Directory Location

Xcode build directory is used to save iOS app binary files when you build your Xcode app. Xcode provide you several ways to specify the build output directory location. It can be a unique sub folder or a shared sub folder in Xcode derived data directory ( in this case all the Xcode projects use one build directory location ), you can also customize the build output folder relative to Xcode derived data directory or relative to your workspace / project or use absolute path. As an iOS developer, it is better for you to know it.

1. How To Configure Xcode Build Directory Location.

You can set Xcode build directory location in Xcode preferences by default or per workspace or per project. Project level build directory location settings will be used first, then workspace settings then Xcode preferences default settings.

1.1 How To Set Xcode Default Build Directory Location.

  1. Click Xcode —> Preferences… menu item at Xcode top menu bar.
    xcode preferences menu item
  2. Then click Locations tab in the popup dialog.  In the Derived Data drop down list, you can choose Default, Relative, Custom drop down item. When you select one item, it will display the build output directory absolute path beneath the Derived Data drop down list.
    xcode - preferences - locations
  3. You can click the Advanced… button to open a Build Location popup dialog to specify the Xcode build directory name and location in detail.
    xcode - preferences - locations - custom - locations
  4. If you choose Unique radio button, then Xcode will add a unique string at the end of the build directory name to make it uniquely. For example /⁨Users/⁨songzhao/⁨Library/⁨Developer⁩/⁨Xcode/⁨DerivedData/⁨SwiftPromptAlertWhenClickButtonExample-aveftcahakzongcarcpgsevmbaur/⁨Build⁩/…….
  5. If you choose Shared Folder radio button, you need to input  shared folder name in the input text box after it. Then the Xcode build output directory is something like this /Users/songzhao/Library/Developer/Xcode/DerivedData/SharedBuild( this is the shared folder name )/Products/Debug-iphonesimulator/……
    xcode - preferences - locations - build location - shared folder
  6. If you choose Custom radio button, then you can select one of the three items from the drop down list, they are Relative to Derived Data, Relative to Workspace and Absolute.
    xcode - preferences - locations - build location - custom
  7. If you select Relative to Derived Data, then the build output directory is something like /Users/songzhao/Library/Developer/Xcode/DerivedData/Build/Products/…….
  8. If you select Relative to Workspace, then the Build directory is saved in the current Xcode workspace folder, it is something like /Users/songzhao/Documents/WorkSpace/……/Build/Products/……, .
  9. If you select Absolute, then you should specify the build output directory absolute path in related input text box accordingly.
    xcode - preferences - locations - build location - custom - absolute
READ :   Swift UIView Animation Example

1.2 How To Set Xcode Workspace Build Directory Location.

Besides Xcode default build directory, you can also specify the build directory for each Xcode workspace. Below is the steps.

  1. Open a workspace in Xcode.
  2. Click File —> Workspace Settings… menu item at top menu bar.
    xcode - file - workspace settings - menu item
  3. It will open the Shared Workspace Settings: popup dialog, you can select different derived data location in the Derived Data drop down list. The value can be Default Location, Workspace-relative Location and Custom Location.
    xcode - shared workspace settings - derived data popup dialog
  4. If you click the Advanced… button, it will popup the workspace Build Location configuration dialog as below. It is similar with the Xcode default build location settings dialog. The only different is that it has a Xcode Default radio button, if you choose this radio button, the Xcode workspace will use Xcode default build location settings.
    xcode - shared workspace location - detail build location

1.3 How To Set Xcode Project Build Directory.

You can also set Xcode build directory location by each project follow below steps.

  1. Open a Xcode project.
  2. Click File —> Project Settings… menu item at top menu bar.
    xcode - file - project settings menu item
  3. In the popup Shared Project Settings: dialog, the Derived Data drop down list contains three item, the second item is Project-relative Location. Others are similar with Shared Workspace Settings dialog.
    xcode - project settings - derived data
  4. When you click the Advanced… button, it will popup the project build location dialog, the content of that dialog is similar with workspace build location dialog.

2. How To Get Current Build Output Directory In Xcode.

When you click Product —> Build menu item in Xcode top menu bar to build your project, it will save the target binary file in the build location directory that you selected. And you can see the binary file in Xcode project navigator pane beneath Products item like below. In this example, the binary file is the red color name .app file under Products item.

READ :   How To Simulate Memory Warning In Xcode 10 iOS Simulator

Please note, if the app binary file name is red color, that means the build is not complete successfully, then you can not open it’s location directory in mac Finder. So you should first make sure the build is complete successfully. When the .app binary file name is not red color, that means the build is success.

xcode project - products - app binary file

If you want to open above app binary file location folder in mac Finder, just right click the binary file under Products folder, then click Show in Finder menu item in the popup menu list. Then it will open Finder and locate the binary file in the project selected build location directory.

show xcode products app binary in finder

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.