Xcode 4 - build output directory
Asked Answered
T

11

219

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.

Teeming answered 20/11, 2010 at 15:55 Comment(0)
P
344

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.

Paulitapaulk answered 26/11, 2010 at 4:7 Comment(5)
This answer explains why this change was made: #5331770Coyne
Proud Member, what do you mean these are not in Xcode 5? They are in Preferences -> Locations -> Derived Data -> Advanced.Removed
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!Padus
@Padus You can also change the derived data location to a path of your own choosingLebrun
@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.)Padus
O
141

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'
Ozonosphere answered 6/5, 2012 at 9:36 Comment(3)
To make my sh scripts working I needed to remove single quotes and write just CONFIGURATION_BUILD_DIR=/Users/...Macrophysics
@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 !Rocket
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/binHong
G
30

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

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

Gleeman answered 21/11, 2013 at 3:47 Comment(1)
May you live to be a hundred years old, strong, and healthy sir. Thank you!Friede
K
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.

Knowledge answered 29/12, 2010 at 15:59 Comment(0)
S
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
Spirometer answered 25/5, 2012 at 23:27 Comment(0)
F
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.

Fefeal answered 7/12, 2010 at 1:50 Comment(2)
And where do I find this build log?? Searching for "build log" in Xcode help returns 0 results.Scoff
Nm, found the "Log Navigator", which looks like a speech bubble.Scoff
V
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.

Vange answered 10/11, 2014 at 14:20 Comment(0)
C
2

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

Clitoris answered 3/1, 2013 at 17:28 Comment(0)
L
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

Leaper answered 31/8, 2011 at 16:3 Comment(5)
no that's unrelated to the derived location / legacy (per target) location behaviorWarlord
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."Leaper
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 2010Warlord
I've actually used this setting to configure the build directory with xcode4 from xcodebuild. Give it a try.Leaper
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"Warlord
D
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.

Decanter answered 22/1, 2015 at 16:24 Comment(0)
J
-1

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

Juliajulian answered 16/5, 2012 at 17:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.