使用Xcode 12中的xcodebuild并为Mac构建,如何防止它尝试为arm64构建?
我正试图通过xcodebuild在命令行上构建一个库的存档(mailcore2(,以便为SPM分发创建一个xcarchive。
在Xcode 11上,此命令运行良好:
xcodebuild archive -scheme "mailcore osx"
-destination "platform=OS X"
-archivePath "$BUILD_DIR/mailcore2.macOS.xcarchive"
SKIP_INSTALL=NO
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
然而,在Xcode 12上,它失败了,并显示了以下消息:
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
看起来它在尝试为arm64(Apple Silicon(构建时失败了,这是有道理的,因为依赖关系还没有为arm Mac构建。现在没什么大不了的,我只为x86_64 Mac构建。经过一些搜索,我发现您可以在-destination
参数下指定架构,如下所示:-destination "platform=OS X,arch=x86_64"
但当我尝试使用它时,以下方法同样失败:
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
有什么想法吗?
好吧,通过对xcodebuild手册页的更多搜索和大量实验,似乎可以直接设置-arch
参数,而不设置-destination
参数:
xcodebuild archive -scheme "mailcore osx"
-arch "x86_64"
-archivePath "$BUILD_DIR/mailcore2.macOS.xcarchive"
SKIP_INSTALL=NO
BUILD_LIBRARY_FOR_DISTRIBUTION=YES