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

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

问题描述

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

生成IPA足够简单,需要进行一些谷歌搜索,但是如何生成.XCARCHIVE文件却使我感到困惑.我找到的最接近的是:

xcodebuild -scheme myscheme archive

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

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

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

解决方案

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

# 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')

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

-重要提示!-

从那以后,我发现找到存档并将其cp到我想要的文件夹的代码行无法正确复制存档内的符号链接,从而破坏了应用程序中的代码签名.您需要将其替换为"mv"或维护符号链接的内容.干杯!

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.

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

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

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?

解决方案

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.

--Important note!--

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天全站免登陆