我已经构建 iOS 应用程序超过 2 年,从未遇到过这个问题。我正在尝试存档一个应用程序以进行 beta 分发。构建成功,但在过程的最后,Xcode 报告“存档已取消”。
构建日志不显示任何警告或错误。
有时,通过清理/清理构建文件夹/擦除派生数据,我可以使存档成功,但似乎没有模式。有没有人遇到过这个问题?在这种情况下,就错误消息而言,我什至没有任何事情要做。
您是否有使用 agvtool 调整版本的自定义运行脚本?我发现这会导致这种确切的行为。几乎 100% 的存档失败,以及常见的构建失败。删除它为我解决了这个问题。
First: +1 on ConfusedNoob's answer, because that was the problem (which led me to numerous experiments and finally this solution.) If my answer helps you, +1 his, too, because his hint was huge!
(Also, see my other answer, below, that bypasses agvtool altogether. I eventually settled-in to using that in all my projects.)
I've been messing with it a bit and the only thing I've found that works reliably to solve it is to use agvtool as a pre-action in the appropriate scheme(s), rather than as a run-script in the build-phases.
Run
and Archive
, but I probably only really need it on archive.Add your agvtool script. If you care, mine is:
cd ${PROJECT_DIR} ; xcrun agvtool next-version -all
(NOTE: pre-actions don't naturally run in ${PROJECT_DIR}
, so you have to cd
.)
Close & save and that's it.
The problem is that agvtool modifies the project file (unnecessarily, since all the build numbers we care about are elsewhere), and modifying the project file causes the build to cancel.
+1 one on the question, too -- cripes, that was a tough one!
另一种技术是完全跳过agvtool
。只需将此运行时脚本添加到构建阶段的末尾(在复制捆绑资源之后)。
Run Script
阶段脚本,便于复制/粘贴:
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
确保您的脚本在构建的复制捆绑阶段之后运行
对我来说,carthage update
构建阶段导致了这个问题。
还要检查您是否有任何其他带有修改文件或代码的脚本的构建阶段。
将其放在前或后操作中(在“编辑方案”对话框中)。它会影响您项目中的所有版本号。
cd "${PROJECT_DIR}" ; agvtool bump
经过大量的测试,我意识到了几件事:
${PROJECT_DIR}
以防止将目录更改为项目文件夹。agvtool
直接访问,而不是使用xcrun
(至少当我安装了 Xcode 命令行工具时,没有它们我还没有尝试过)我有同样的问题。但我在仍然使用时修复了它avgtool
。
我使用Build Phases
Run Script
not作为最后一步,并使用了以下导致错误的脚本:
"${DEVELOPER_BIN_DIR}/agvtool" next-version -all
我的解决方案是Build Phases
Run Script
用作最后阶段并将脚本更改为以下
agvtool bump