我们有一个工具,可以使用 xcodebuild 命令行工具在内部创建 iPhone 版本。在 Xcode14.3 发布之前一切正常。下面是我的构建命令
它使用 SYMROOT 和 DSTROOT 参数将构建复制到项目中的特定位置。
buildOutput=$PWD"/"$relativePath"/output"
relativePath is actually the path towards my iOS project
所有其他参数均已传递且工作正常。但是当我使用 DSTROOT
时,出现以下错误
xcodebuild: error: “InstallationBuildProductsLocation” couldn’t be moved to “AdHoc 09-05-2023, 4.26 pm 2.xcarchive” because either the former doesn’t exist, or the folder containing the latter doesn’t exist.: The operation couldn’t be completed. No such file or directory
下面是完整的错误堆栈
2023-05-09 16:26:55.609 xcodebuild[24614:1420687] Writing error result bundle to /var/folders/vt/bxdl1j6x111fjsjmw5r11s680000gn/T/ResultBundle_2023-09-05_4-26-0055 pm.xcresult
xcodebuild: error: “InstallationBuildProductsLocation” couldn’t be moved to “AdHoc 09-05-2023, 4.26 pm 2.xcarchive” because either the former doesn’t exist, or the folder containing the latter doesn’t exist.: The operation couldn’t be completed. No such file or directory
但令我惊讶的是,在 output
目录下我可以看到 .app 生成的 (output/Applications/myApp.app)
我不确定为什么构建失败在这种情况下。由于失败,我无法继续构建脚本的下一步。有人可以帮我吗?我花了很多时间但无法找到这个问题背后的原因。请帮忙。
最佳答案
将系统更新到 macOS 13.x 和 Xcode 14.x(从 macOS 12.x 和 Xcode 13.x)后,我开始从库构建脚本中收到完全相同的错误消息
通过反复试验,我得出的结论是,在归档我的库产品以进行分发时,新的 Xcode 不再“喜欢”将 SYMROOT 和 DSTROOT 路径/内容与派生数据路径/内容分开。
对我有用的是开始使用衍生数据路径
和archivePath
而不是SYMROOT
和DSTROOT
。
像这样:
xcodebuild -workspace $product.xcworkspace -scheme $scheme -destination "generic/platform=iOS" clean archive -quiet ENABLE_BITCODE=NO OTHER_SWIFT_FLAGS='$(inherited) -D EXTERNAL' SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES -derivedDataPath $(PWD)/tmp-derived-data -archivePath $(PWD)/tmp-derived-data/$productName
if [[ $? == 0 ]]; then
echo "Success"
else
echo "Failed"
error_exit "Error: Exit code: $?"
fi
我现在可以在与以前略有不同的位置找到构建的框架产品:
tmp-derived-data/$product.xcarchive/Products/Library/Frameworks/$productName.framework
也许这也能帮助您解决问题。
这是我之前的:
xcodebuild -workspace $productName.xcworkspace -scheme $scheme -destination "generic/platform=iOS" clean archive -quiet SYMROOT=$(PWD)/tmp-build-symroot DSTROOT=$(PWD)/tmp-build-dstroot ENABLE_BITCODE=NO OTHER_SWIFT_FLAGS='$(inherited) -D EXTERNAL' SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES
关于ios - Xcode14.3 中带有参数 DSTROOT 的 xcodebuild 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76211224/