[英]xcodebuild archive fails, xcode archive succeeds
I am attempting to automate the submission process to iTunesConnect using a shell script and the command line tools from Xcode. 我正在尝试使用shell脚本和Xcode的命令行工具自动将提交过程自动化到iTunesConnect。 So far, I have managed to achieve every step in the process bar one: archive.
到目前为止,我已经成功实现了流程栏中的每一步:存档。
The code from the script: 脚本中的代码:
echo "Attempting to build target: ${TARGET_PRODUCT}"
cd $ENGINE_PATH
# Clean
/usr/bin/xcodebuild clean -project projName.xcodeproj -target "${TARGET_PRODUCT}" -configuration Release
# Build and Archive
/usr/bin/xcodebuild archive -project projName.xcodeproj -scheme "${TARGET_PRODUCT}" -configuration Release -archivePath "${TARGET_PRODUCT}".xcarchive
So far, the archive command has been unable to create an archive successfully. 到目前为止,archive命令无法成功创建存档。 The only output from this command is:
** ARCHIVE FAILED **
. 此命令的唯一输出是:
** ARCHIVE FAILED **
。
If I just try to build, rather than archive, I get: ** BUILD SUCCEEDED **
如果我只是尝试构建,而不是存档,我得到:
** BUILD SUCCEEDED **
The archive does produce a file at the expected location and 'Show Package Contents' expands to show a directory structure identical to archives produced within Xcode with one exception, the archive created within Xcode includes an additional folder called SCMBlueprint
. 存档确实在预期位置生成文件,并且“显示包内容”展开以显示与Xcode中生成的存档相同的目录结构,但有一个例外,在Xcode中创建的存档包括一个名为
SCMBlueprint
的附加文件夹。
I've seen on other forum posts that issues with archiving are often due to Code Sign or Provisioning Profile issues. 我在其他论坛帖子上看到,归档问题通常是由于代码签名或配置文件问题。 However, I'm not convinced this is an issue in this case, as during the build and archiving process the Code Sign Identity and Provisioning Profiles used are output in the console.
但是,在这种情况下,我不相信这是一个问题,因为在构建和归档过程中,使用的代码签名身份和配置文件在控制台中输出。 My failed archiving is using the same Code Sign Identity and Provisioning Profile that successful builds are using.
我失败的归档使用了成功构建所使用的相同代码签名标识和供应配置文件。 In addition, I produced an archive using Xcode and looked within that archive for the
embedded.mobileprovision
file. 此外,我使用Xcode生成了一个存档,并在该存档中查找了
embedded.mobileprovision
文件。 I compared this to the failed archive generated by xcodebuild
and could see that they are identical. 我将此与
xcodebuild
生成的失败存档进行了比较,可以看出它们是相同的。
I've looked elsewhere online for any suggestions for what is causing the archiving by xcodebuild
to fail, but so far, I am stumped! 我已经在网上寻找任何有关导致
xcodebuild
归档失败的建议,但到目前为止,我很难过! Any help is much appreciated! 任何帮助深表感谢!
Please check if you do not have any errors during archive process. 请检查存档过程中是否有任何错误。 Also please compare the logs between Xcode and command line output, it may help you understanding on which step compilation fails.
另外请比较Xcode和命令行输出之间的日志,它可以帮助您了解编译失败的步骤。
I had the same issue. 我遇到过同样的问题。 Archive was failing without any specific reason, while .xcarchive was produced.
存档失败没有任何特定原因,而.xcarchive已生成。 I looked at build logs from xcode noticed that it finished with
Build finished with errors
message. 我查看了来自xcode的构建日志,注意到它完成了
Build finished with errors
消息。 Despite this error organizer was showing archive and I was able to export IPA from it. 尽管有这个错误,组织者显示存档,我能够从中导出IPA。
When I reviewed that, I found out there was an archive error caused by broken PNG file, which couldn't be compressed during archive process. 当我查看它时,我发现存在由PNG文件损坏导致的存档错误,该文件在存档过程中无法压缩。 Error was non fatal, hence archive was being produced anyway.
错误是非致命的,因此无论如何都会生成存档。 When I fixed PNG file everything started compiling smoothly without any issues.
当我修复PNG文件时,一切都开始顺利编译没有任何问题。
This just happened to me, and it was for a different issues than with PNGs (maybe what follows is just the more general case though): I had a custom build phase which was outputting errors to stderr
, but the build phase wasn't returning an exit code different from 0
in this case (using xcodebuild
from Xcode 9.3 (9E145)
). 这恰好发生在我身上,它出现了与PNG不同的问题(可能下面的内容只是更一般的情况):我有一个自定义构建阶段,它向
stderr
输出错误,但构建阶段没有返回在这种情况下退出代码不同于0
(使用Xcode 9.3 (9E145)
xcodebuild
)。
The build phase was similar to: 构建阶段类似于:
find "${SRCROOT}/Directory" -print0 | <...>
Where ${SRCROOT}/Directory
was renamed , and so find
would output an error without failing the script: the build log would contain Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure
right after executing the build phase. 其中
${SRCROOT}/Directory
已重命名 ,因此find
会在不使脚本失败的情况下输出错误:构建日志将包含Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure
在执行构建后Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure
相。
While Xcode itself has no issues with it, xcodebuild
would simply fail with **ARCHIVE FAILED**
at the end, right after touching the DSYM. 虽然Xcode本身没有问题,但
xcodebuild
在触及DSYM后,最终会在**ARCHIVE FAILED**
。
The fix was to make sure that if a build phase outputs to stderr
, the build phase correctly explicitely returns an exit code different from 0
(like 1
). 修复是为了确保如果构建阶段输出到
stderr
,构建阶段正确地明确地返回不同于0
的退出代码(如1
)。 In my case, changing the path referenced in find
fixed the issue. 在我的情况下,更改
find
引用的路径修复了问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.