Reputation: 3026
Am I misunderstanding what -derivedDataPath
does, or is this a bug? You can clearly see in the output that xcodebuild is ignoring the command-line value, and defaulting to Library/Developer/Xcode/DerivedData
.
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project MyProj.xcodeproj -scheme “MyProj (iOS)" -destination "name=iPhone 12" -derivedDataPath=/Users/alpe77/myproj/MyProj/Build build
User defaults from command line:
derivedDataPath = /Users/alpe77/myproj/MyProj/Build
IDEPackageSupportUseBuiltinSCM = YES
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Analyzing workspace
note: Using build description from disk
note: Build preparation complete
CodeSign /Users/alpe77/Library/Developer/Xcode/DerivedData/MyProj-aozsidihjyumkvevtfoqflhumohn/Build/Products/Debug-iphonesimulator/MyProj.app (in target 'MyProj (iOS)' from project 'MyProj')
cd /Users/alpe77/myproj/MyProj
export CODESIGN_ALLOCATE\=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
Signing Identity: "-"
/usr/bin/codesign --force --sign - --entitlements
/Users/alpe77/Library/Developer/Xcode/DerivedData/MyProj-aozsidihjyumkvevtfoqflhumohn/Build/Intermediates.noindex/MyProj.build/Debug-iphonesimulator/MyProj\ \(iOS\).build/MyProj.app.xcent --timestamp\=none
/Users/alpe77/Library/Developer/Xcode/DerivedData/MyProj-aozsidihjyumkvevtfoqflhumohn/Build/Products/Debug-iphonesimulator/MyProj.app
/Users/alpe77/Library/Developer/Xcode/DerivedData/MyProj-aozsidihjyumkvevtfoqflhumohn/Build/Products/Debug-iphonesimulator/MyProj.app: replacing existing signature
** BUILD SUCCEEDED ** [0.771 sec]
% xcrun xcodebuild -version
Xcode 12.5.1
Build version 12E507
Upvotes: 1
Views: 2153
Reputation: 1847
From what I could figure out, at least for Xcode 13, xcodebuild ignores -derivedDataPath
for build products/intermediates, if they're overridden in Xcode defaults, in e.g. Xcode Preferences > Locations > Derived Data > Advanced - they're derived from Derived Data set in Xcode defaults, not from the one passed to xcodebuild. As a workaround, we can "clear" those defaults as well, when invoking xcodebuild like below (luckily they're clearly visible in the list of defaults for com.apple.dt.Xcode, as IDECustomBuildProductsPath and IDECustomBuildIntermediatesPath, and xcodebuild supports overriding the custom defaults in general by passing -userdefault=value
):
xcodebuild -derivedDataPath /custom/path -IDECustomBuildProductsPath="" -IDECustomBuildIntermediatesPath="" ...
Upvotes: 0
Reputation: 894
Had the same problem (Xcode 12.4) and found out that the build environment configuration variable CONFIGURATION_BUILD_DIR
overrides the path given in -derivedDataPath
I opened "Xcode Preferences > Locations > Derived Data > Advanced" and changed the build location setting from my custom setting to "Unique" which solved the problem.
Would be interested in how to prevent CONFIGURATION_BUILD_DIR
from overriding -derivedDataPath
on the command line, though...
Edit
See https://stackoverflow.com/a/35662727/403750 for a solution.
Upvotes: 1