Using xcodebuild from Xcode 12 and building for Mac, how do I prevent it from attempting to build for arm64?
I'm trying to build an archive of a library (mailcore2) on the command line via xcodebuild for the purposes of creating an xcarchive for SPM distribution.
On Xcode 11, this command works fine:
xcodebuild archive -scheme "mailcore osx" \
-destination "platform=OS X" \
-archivePath "$BUILD_DIR/mailcore2.macOS.xcarchive" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
On Xcode 12, however, it's failing with this message:
The following build commands failed:
Ld /Users/<USER>/Library/Developer/Xcode/DerivedData/mailcore2-fuubwipfjyvskpfsxtortvjsugny/Build/Intermediates.noindex/ArchiveIntermediates/mailcore\ osx/IntermediateBuildFilesPath/mailcore2.build/Release/mailcore\ osx.build/Objects-normal/arm64/Binary/MailCore normal arm64
Looks like it's failing when trying to build for arm64 (Apple Silicon), which makes sense since the dependencies aren't built for arm Macs yet. Not a big deal for now, I'll just build only for x86_64 Macs. After some searching I found you can specify architecture under the -destination
argument like this: -destination "platform=OS X,arch=x86_64"
But when I try to use that the following just fails the same way:
xcodebuild archive -scheme "mailcore osx" \
-destination "platform=OS X,arch=x86_64" \
-archivePath "$BUILD_DIR/mailcore2.macOS.xcarchive" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
Any ideas?
Okay, so with some more scouring of the xcodebuild man page and lots of experimenting, it seems like setting the -arch
argument directly and leaving off the -destination
argument accomplishes it:
xcodebuild archive -scheme "mailcore osx" \
-arch "x86_64" \
-archivePath "$BUILD_DIR/mailcore2.macOS.xcarchive" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES