从命令行生成 xcarchive 到特定文件夹 [英] Generate xcarchive into a specific folder from the command line

查看:44
本文介绍了从命令行生成 xcarchive 到特定文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于 CI 的目的,我需要能够在每晚构建中生成 XCARCHIVE 和 IPA 文件.IPA 供我们的测试人员使用,使用我们的临时密钥签名,XCARCHIVE 将发送给客户端,以便他们可以将其导入 Xcode 并在他们满意时将其提交到应用商店.

For the purposes of CI, I need to be able to generate an XCARCHIVE and an IPA file in our nightly build. The IPA is for our testers, to be signed with our ad-hoc keys, and the XCARCHIVE is to send to the client so that they can import it into Xcode and submit it to the app store when they're happy with it.

通过一些谷歌搜索,生成 IPA 很简单,但是如何生成 .XCARCHIVE 文件是我所不知道的.我找到的最接近的是:

Generating the IPA is simple enough with a bit of googling, however how to generate the .XCARCHIVE file is what eludes me. The closest I've found is:

xcodebuild -scheme myscheme archive

然而,这会将 .xcarchive 存储在一些难以找到的文件夹中,例如:

However, this stores the .xcarchive in some hard-to-find folder, eg:

/Users/me/Library/Developer/Xcode/Archives/2011-12-14/MyApp 14-12-11 11.42 AM.xcarchive

有什么方法可以控制存档的放置位置、名称是什么,以及如何避免重新编译它?我想最好的结果是从执行xcodebuild 构建"时生成的 DSYM 和 APP 生成 xcarchive - 这可能吗?

Is there some way to control where the archive is put, what its name is, and how to avoid having to re-compile it? I guess the best possible outcome would be to generate the xcarchive from the DSYM and APP that are generated when you do an 'xcodebuild build' - is this possible?

推荐答案

我目前的解决方案是重命名用户现有的档案文件夹,运行构建,并执行查找"以将档案复制到我想要的位置,然后删除archives 文件夹并将旧文件夹重命名为原样,在我的 ruby​​ 构建脚本中使用如下代码:

My current solution is to rename the user's existing archives folder, run the build, and do a 'find' to copy the archives where i want, then delete the archives folder and rename the old folder back as it was, with code like this in my ruby build script:

# Move the existing archives out of the way
system('mv ~/Library/Developer/Xcode/Archives ~/Library/Developer/Xcode/OldArchivesTemp')
# Build the .app, the .DSYM, and the .xcarchive
system("xcodebuild -scheme \"#{scheme}\" clean build archive CONFIGURATION_BUILD_DIR=\"#{build_destination_folder}\"")
# Find the xcarchive wherever it was placed and copy it where i want it
system("find ~/Library/Developer/Xcode/Archives -name *.xcarchive -exec cp -r {} \"#{build_destination_folder}\" \";\"")
# Delete the new archives folder with this new xcarchive
system('rm -rf ~/Library/Developer/Xcode/Archives')
# Put the old archives back
system('mv ~/Library/Developer/Xcode/OldArchivesTemp ~/Library/Developer/Xcode/Archives')

它有点老套,但我目前没有看到更好的解决方案.至少它保留了用户的档案"文件夹及其所有预先存在的档案.

Its a bit hacky but i don't see a better solution currently. At least it preserves the user's 'archives' folder and all their pre-existing archives.

--重要提示!--

我发现我找到存档并将其cp到我想要的文件夹的代码行没有正确复制存档内的符号链接,从而破坏了应用程序中的代码签名.你会想用mv"或维护符号链接的东西来替换它.干杯!

I since found out that the line of code where i find the archive and cp it to the folder i want doesn't copy the symlinks inside the archive correctly, thus breaking the code signing in the app. You'll want to replace that with a 'mv' or something that maintains symlinks. Cheers!

这篇关于从命令行生成 xcarchive 到特定文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆