217

I have problems with setting up/locating my output files in Xcode4 (beta 5). They are placed somewhere in ~/Library/Developer/ugly_path/.... I can't even select "show in finder" on my products. It is the same for a simple C project, Foundation tool and even Cocoa bundle. A Debugging works fine.

Could you please point me out where and how to set up / build output directories? (I know it sounds dumb, I've been coding in Xcode3 for months, but I can't figure it out in Xcode4 beta).

Thanks a lot.

idmean
  • 14,540
  • 9
  • 54
  • 83
kubbing
  • 7,219
  • 4
  • 23
  • 18

11 Answers11

343

From the Xcode menu on top, click preferences, select the locations tab, look at the build location option.

You have 2 options:

  1. Place build products in derived data location (recommended)
  2. Place build products in locations specified by targets

Update: On xcode 4.6.2 you need to click the advanced button on the right side below the derived data text field. Build Location select legacy.

Ramy Al Zuhouri
  • 21,580
  • 26
  • 105
  • 187
the Reverend
  • 12,305
  • 10
  • 66
  • 121
  • 27
    This answer explains why this change was made: http://stackoverflow.com/questions/5331270/why-doesnt-xcode-4-create-any-products – toofah Mar 25 '11 at 22:48
  • 3
    Proud Member, what do you mean these are not in Xcode 5? They are in Preferences -> Locations -> Derived Data -> Advanced. – Richard Venable Dec 16 '13 at 18:36
  • Ok, so my build goes into the `.../XCode/DerivedData/` folder, simple enough. Except that the subfolders seem to be `AppName-asdflkjqwergoobledygook`. Since I'm building from a script, I'd like to actually *find* the build (so I can package it and send via TestFlight :) How do I determine which of the many `MyAppName-xxxx`-s is the right one? Thanks! – Olie Oct 02 '14 at 04:02
  • @Olie You can also change the derived data location to a path of your own choosing – Gerard Oct 21 '14 at 20:48
  • @Gerard: I could, but that's not what I want to do. I'm checking out sources from a repo, then building via command line, and I want to know where the build went. It would be inappropriate for my build-script to modify the project in any way (say, by changing the project settings.) – Olie Oct 21 '14 at 23:58
140

If you build from command line, you can set output directory in the following way:

xcodebuild -workspace 'WORKSPACE_NAME.xcworkspace' \
           -scheme 'SCHEME_NAME' \
           -configuration 'Release' \
           -sdk iphoneos7.0 CONFIGURATION_BUILD_DIR='OUTPUT_DIRECTORY'
Igor
  • 4,235
  • 3
  • 34
  • 32
  • To make my sh scripts working I needed to remove single quotes and write just CONFIGURATION_BUILD_DIR=/Users/... – Stanislav Pankevich Oct 31 '13 at 02:53
  • @occulus, you're absolutely right as this will fail building the testing target after building the project, I think if you're just building it MIGHT be okay, but better use absolute paths ! – Mostafa Berg Jun 02 '14 at 14:56
  • In case anyone else is trying to solve a similar problem I convinced XCode 6.x to place the linked binary *exactly* where it was needed using this combination: ```/Users/moi/src/mozbuilds/xul3604/$(CONFIGURATION)/dist/bin``` – J Evans Mar 30 '15 at 16:06
29

In Xcode 5: Xcode menu > Preferences... item > Locations tab > Locations sub-tab > Advanced... button > Custom option.

Then choose, e.g., Relative to Workspace.

Grumdrig
  • 16,588
  • 14
  • 58
  • 69
13

If you have Xcode 4 Build Location setting set to "Place build products in derived data location (recommended), it should be located in ~/Library/Developer/Xcode/DerivedData. This directory will have your project in there as a directory, the project name will be appended with a bunch of generated letters so look carefully.

Tim Sylvester
  • 22,897
  • 2
  • 80
  • 94
bxiong
  • 179
  • 1
  • 10
10

Keep derived data but use the DSTROOT to specify the destination.

Use DEPLOYMENT_LOCATION to force deployment.

Use the undocumented DWARF_DSYM_FOLDER_PATH to copy the dSYM over too.

This allows you to use derived data location from xcodebuild and not have to do wacky stuff to find the app.

xcodebuild -sdk "iphoneos" -workspace Foo.xcworkspace -scheme Foo -configuration "Debug" DEPLOYMENT_LOCATION=YES DSTROOT=tmp DWARF_DSYM_FOLDER_PATH=tmp build
Gabriel
  • 964
  • 9
  • 8
8

You can always find the build directory by looking in the build log viewer, and copying the path there into a terminal window.

I use this to analyze my iOS .app bundles before they get installed to make sure no stray files are being included.

Tim Sylvester
  • 22,897
  • 2
  • 80
  • 94
radven
  • 2,296
  • 1
  • 22
  • 39
4

For anyone who wants to find the build directory from a script but does not want to change it, run the following to get a list of all the build settings that point to a folder in DerivedData:

xcodebuild -showBuildSettings | grep DerivedData

If you run custom targets and schemes, please put them there as well:

xcodebuild -workspace "Foo.xcworkspace" -scheme "Bar" -sdk iphonesimulator -configuration Debug -showBuildSettings | grep DerivedData

Look at the output to locate the setting output that you want and then:

xcodebuild -showBuildSettings | grep SYMROOT | cut -d "=" -f 2 - | sed 's/^ *//'

The last part cuts the string at the equal sign and then trims the whitespace at the beginning.

2

If you use the new Xcode4 Workspaces, you can change the Derived Data Location under File -> Workspace settings...

DaGaMs
  • 1,521
  • 17
  • 26
1

You can configure the output directory using the CONFIGURATION_BUILD_DIR environment variable.

Source: http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/0-Introduction/introduction.html#//apple_ref/doc/uid/TP40003931-CH1-SW1

Heath Borders
  • 30,998
  • 16
  • 147
  • 256
  • no that's unrelated to the derived location / legacy (per target) location behavior – Gregory Pakosz Mar 13 '12 at 15:17
  • Yes it is. It works either way. From the documentation: "Directory path. Identifies the directory under which all build-related files for the active build configuration are placed." – Heath Borders Mar 13 '12 at 19:16
  • nope. not with xcode4 it depends on `Xcode > Preferences > Locations > Derived data` setting as explained in the most voted answer. + the document you're referring to was last updated in 2010 – Gregory Pakosz Mar 13 '12 at 19:40
  • I've actually used this setting to configure the build directory with xcode4 from xcodebuild. Give it a try. – Heath Borders Mar 13 '12 at 21:18
  • 1
    well I've tried with Xcode 4.3.1 (from the IDE) and without changing the global setting, products are build somewhere in `~/Library/Developer/Xcode/DerivedData/` and not inside the directory I specify with `CONFIGURATION_BUILD_DIR`. If I want `CONFIGURATION_BUILD_DIR` to be honored, I have to switch Xcode derived data preferences to "Legacy" – Gregory Pakosz Mar 13 '12 at 23:36
0

Another thing to check before you start playing with Xcode preferences is:

Select your target and go to Build Settings > Packaging > Wrapper Extension

The value there should be: app

If not double click it and type "app" without the qoutes.

hasan
  • 23,815
  • 10
  • 63
  • 101
-1

This was so annoying. Open your project, click on Target, Open Build Phases tab. Check your Copy Bundle Resources for any red items.