12

我已经构建 iOS 应用程序超过 2 年,从未遇到过这个问题。我正在尝试存档一个应用程序以进行 beta 分发。构建成功,但在过程的最后,Xcode 报告“存档已取消”。

在此处输入图像描述

构建日志不显示任何警告或错误。

在此处输入图像描述

有时,通过清理/清理构建文件夹/擦除派生数据,我可以使存档成功,但似乎没有模式。有没有人遇到过这个问题?在这种情况下,就错误消息而言,我什至没有任何事情要做。

4

7 回答 7

51

您是否有使用 agvtool 调整版本的自定义运行脚本?我发现这会导致这种确切的行为。几乎 100% 的存档失败,以及常见的构建失败。删除它为我解决了这个问题。

于 2013-06-02T17:29:19.373 回答
31

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.

  • CMD-SHIFT-comma to edit schemes (XCode 6.x)
  • Twiddle-open whichever scheme you want this on. I did it on Run and Archive, but I probably only really need it on archive.
  • Select the "+" icon and "New run script action"
  • 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!

于 2015-04-29T01:42:26.067 回答
3

另一种技术是完全跳过agvtool。只需将此运行时脚本添加到构建阶段的末尾(在复制捆绑资源之后)。

  • 选择您的项目

选择您的项目

  • 选择构建阶段和 +

选择构建阶段和 +

  • 添加新Run Script阶段

添加新的运行脚本阶段

  • 输入脚本

输入脚本

脚本,便于复制/粘贴:

buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"

确保您的脚本在构建的复制捆绑阶段之后运行

于 2015-05-25T13:12:19.533 回答
1

对我来说,carthage update构建阶段导致了这个问题。

还要检查您是否有任何其他带有修改文件或代码的脚本的构建阶段。

于 2016-06-02T09:07:10.233 回答
1

Xcode 13.2.1 - 超级简单

将其放在前或后操作中(在“编辑方案”对话框中)。它会影响您项目中的所有版本号。

cd "${PROJECT_DIR}" ; agvtool bump

这是我关于这个主题的简短博客文章

经过大量的测试,我意识到了几件事:

  • 很多答案都省略了引号,${PROJECT_DIR}以防止将目录更改为项目文件夹。
  • 我们可以agvtool直接访问,而不是使用xcrun(至少当我安装了 Xcode 命令行工具时,没有它们我还没有尝试过)
  • 当构建阶段脚本使用 agvtool 修改项目文件时,新的构建系统会阻止归档成功完成。
于 2022-03-03T21:19:21.047 回答
0

我有同样的问题。但我在仍然使用时修复了它avgtool

我使用Build Phases Run Script not作为最后一步,并使用了以下导致错误的脚本:

"${DEVELOPER_BIN_DIR}/agvtool" next-version -all

我的解决方案Build Phases Run Script用作最后阶段并将脚本更改为以下

agvtool bump
于 2020-06-22T09:32:48.010 回答
0

就我而言,在更新我的 XCode 版本后,我开始经常遇到这个问题。这是我为解决它所做的:

  1. 单击 XCode 顶部栏上的“锤子”图标。在此处输入图像描述

  2. 在 Build System 选项卡中选择“Legacy Build System”。

  3. 点击完成。

如果您正在处理较旧的项目并且所有内容似乎都已编译,则应用程序应该在此之后构建而不会出现此问题。

于 2020-02-05T07:11:59.520 回答