Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcodebuild'ing a workspace and setting a custom build path

I'm trying to use xcodebuild to build a multi-project project in a workspace. When XCode builds a workspace it automatically places all build artifacts in a common directory in DerivedData so that each project can access it dependencies.

If I use this command:

xcodebuild -workspace myWorkspace.xcworkspace -schema builtIt -configuration Release 

Eveything works, but the artifacts are placed in usual derived data directory. I want then to appear in a specific directory which I can access from CI builds. So I tried this

xcodebuild -workspace myWorkspace.xcworkspace -schema builtIt -configuration Release SYMROOT=build/products OBJROOT=build/intermediates 

However xcodebuild fails with this saying

Details:  Failed to load dependencies output contents from ``/Users/d4rkf1br3/projects/dNodi/build/intermediates/dNodi.build/Debug-iphoneos/dNodi.build/StaticAnalyzer/normal/armv7/DNRootSelector.d''.  Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “DNRootSelector.d” couldn’t be opened because there is no such file."  UserInfo=0x4012fea40 {NSFilePath=/Users/d4rkf1br3/projects/dNodi/build/intermediates/dNodi.build/Debug-iphoneos/dNodi.build/StaticAnalyzer/normal/armv7/DNRootSelector.d, NSUnderlyingError=0x4012fc240 "The operation couldn’t be completed. No such file or directory"}.  User info: {     NSFilePath = "/Users/d4rkf1br3/projects/dNodi/build/intermediates/dNodi.build/Debug-iphoneos/dNodi.build/StaticAnalyzer/normal/armv7/DNRootSelector.d";     NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\""; } 

The problem appears to be that xcodebuild is no longer using a central directory for all projects in the workspace and is storing the artifacts in each project instead. Hence it cannot locate the dependencies between code being compiled and artifacts produced in other projects.

Does anyone know the correct parameter to set on the command line?

Xcode's Build Setting Reference has not been updated for two years so I don't know if there are new build settings I can apply.

like image 926
drekka Avatar asked Aug 15 '12 06:08

drekka


2 Answers

I'm not sure if this is a new option but the 5.0 release of xcodebuild has an option -derivedDataPath which allows you to specify the directory you'd like all the build products to sit in.

For instance, passing -derivedDataPath build creates the folder build relative to where you ran xcodebuild from, and you can find your app predictably in a subfolder like build/Build/Products/Release-iphoneos.

Documentation: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html

like image 109
Nick Farina Avatar answered Oct 06 '22 00:10

Nick Farina


The best solution i have found so far is to use the CONFIGURATION_BUILD_DIR parameter with an ABSOLUTE path (e.g. /tmp/$PROJECT/build). Like this:

xcodebuild -scheme "scheme" -configuration Debug -sdk iphoneos clean build CONFIGURATION_BUILD_DIR=$ABSOLUTE_BUILD_PATH 

I use Jenkins and there I have an variable named $WORKSPACE. With $WORKSPACE/build as my CONFIGURATION_BUILD_DIR I have a solution I'm happy with.

The relative paths don't seem to work as expected. We should file a bug report.

like image 41
Chilloutman Avatar answered Oct 06 '22 00:10

Chilloutman