Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcode4: reliably detect the DerivedData directory of a project/workspace

Tags:

xcode

ios

build

Xcode 4 builds everything into $HOME/Library/Developer/Xcode/DerivedData/$PROJECT-$UUID, where $UUID is a seemingly random string (it's not really random, it just looks random).

How can I reliably detect the $PROJECT-$UUID part of the above? I've seen a script (https://gist.github.com/949831) that guesses by assuming it is the last modified directory in DerivedData -- but that's not true if my CI machine is building a few projects in parallel.

like image 612
noamtm Avatar asked May 23 '11 14:05

noamtm


People also ask

Where to find derived data in Xcode?

My DerivedData folder is supposed to be in Library/Developer/Xcode/DerivedData.

Where is the derived data folder on Mac?

You'll find your derived data folder in your macOS user library. To find your derived data folder, open a new Finder window. In the Finder menu bar, select Go ▸ Go to Folder…. Click Go to change the Finder window's path to DerivedData.

How do I clear derived data Xcode 13?

Delete Derived DataChoose Window -> Organizer. Select the Projects tab. Select your project on the left. Next to the Derived Data line, there click the Delete button.

What is derivedDataPath?

-derivedDataPath PATH specifies the directory where build products and other derived data will go ... (See e.g: https://stackoverflow.com/questions/33044633/command-line-option-to-change-xcode-deriveddata-location ) Keep in mind, depending on your Xcode project configs changing the derived data dir might cause issues.


1 Answers

Nobody answered, so I kept looking for ideas until I found the one below, which satisfies my needs. It can be further modified to be even safer.

  1. In Xcode, add a run-script build phase to the target (the main target, if building a few for the same project).
  2. In the script, put this line:

ln -sf "$BUILD_DIR" BuildDir

Now, when the target is built a symlink to the project's DerivedData directory will be created in the project directory. If desirable, you can also/instead create BuildDir as a file who's content is the $BUILD_DIR:

echo "$BUILD_DIR" > BuildDir

Then in a script use $(cat BuildDir) to retrieve it.

like image 105
noamtm Avatar answered Nov 12 '22 01:11

noamtm