naz
naz

Reputation: 1516

How to get the Xcode build directory?

How do I get the URL or url string to the build directory of a workspace or a project? I don't want to set it myself to know what it is instead I want to know the default set by Xcode.

How to get the directory programmatically?

Upvotes: 5

Views: 17670

Answers (3)

Olivier
Olivier

Reputation: 809

Building up on Daniel Jones answer above, to get the BUILD_DIR of a workspace, you should run:

xcodebuild -workspace ios/myApp.xcworkspace -scheme myApp -showBuildSettings | grep BUILD_DIR

example of response:

BUILD_DIR = /Users/Olivier/Library/Developer/Xcode/DerivedData/myApp-ceetrcnutlegngflgvvfjaaaycrc/Build/Products

Upvotes: 4

Daniel Jones
Daniel Jones

Reputation: 693

If you need the build directory path for use within an Xcode build script (Build Phases > Run Script), then use the following variable:

$TARGET_BUILD_DIR

For an exhaustive list of all variables exposed by Xcode in build scripts, follow this answer:

$ xcodebuild -project myProject.xcodeproj -target "myTarget" -showBuildSettings

Upvotes: 6

Sergio
Sergio

Reputation: 1852

Select you project in the Xcode. On the right side select "Build Settings". Select desired target and under "Build Locations" you will find paths for debug, release and distribution configurations. These paths are relative to your "Deriver Data" directory. To open that directory in Finder, do the following. Xcode menu: Window->Organizer. When you get "Organizer" window, on the left side select you project and on the right side you will get "Derive Data" path. Clicking on the arrow at the end of the "Derived Data" path you will open that directory in the Finder.

If you want a build directory path to use in some Pre-actions or Post-actions scripts, then variable name for it can be found in Quick Help Inspector, once you clicked on desired build directory in "Build Locations".

enter image description here

enter image description here

Upvotes: 0

Related Questions