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.
I also met this problem when I build my project from Jenkins CI tool. My main project depends a sub-project. I have tried building follow @Chilloutman's solution like this:
or
Both of them occur errors
Could not find iphoneos in /Users/mobileserver/jenkins_home/jobs/TravelGuide-Buid-For-Me/workspace/build
But I get success finally using this:
That is: Setting the SYMROOT with a absolute paths.
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:I use Jenkins and there I have an variable named
$WORKSPACE
. With$WORKSPACE/build
as myCONFIGURATION_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.
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 folderbuild
relative to where you ranxcodebuild
from, and you can find your app predictably in a subfolder likebuild/Build/Products/Release-iphoneos
.Documentation: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html