Xcode 4 - build output directory
IdeXcode4Ide Problem Overview
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.
Ide Solutions
Solution 1 - Ide
From the Xcode menu on top, click preferences, select the locations tab, look at the build location option.
You have 2 options:
- Place build products in derived data location (recommended)
- 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.
Solution 2 - Ide
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'
Solution 3 - Ide
In Xcode 5: Xcode menu > Preferences... item > Locations tab > Locations sub-tab > Advanced... button > Custom option.
Then choose, e.g., Relative to Workspace.
Solution 4 - Ide
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.
Solution 5 - Ide
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
Solution 6 - Ide
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.
Solution 7 - Ide
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.
Solution 8 - Ide
If you use the new Xcode4 Workspaces, you can change the Derived Data Location under File -> Workspace settings...
Solution 9 - Ide
You can configure the output directory using the CONFIGURATION_BUILD_DIR
environment variable.
Solution 10 - Ide
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.
Solution 11 - Ide
This was so annoying. Open your project, click on Target, Open Build Phases tab. Check your Copy Bundle Resources for any red items.