仅针对Xcode 4中的“存档"构建运行脚本 [英] Running script only for an 'Archive' build in Xcode 4

查看:74
本文介绍了仅针对Xcode 4中的“存档"构建运行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,该脚本是在Xcode 4的运行脚本构建"阶段中使用osascript运行的.该脚本进行了一些检查,以尝试捕获钉子之类的人为错误.

I have a script that I run using osascript from a Run Script Build Phase in Xcode 4. This script does some checks to try and catch any human-error in plists and suchlike.

但是,我只想在开发人员选择存档"时才运行此脚本,而不是在每次构建时都运行它.

However, I only really want to run this script when a developer chooses 'Archive' as opposed to running it every time they build.

有什么方法可以测试这种情况?是使用Shell脚本还是Apple脚本?

Is there any way of testing for this situation? Either in Shell Script or Apple Script?

推荐答案

在Xcode 4+中,您可以将此脚本作为存档"操作的操作前或操作后脚本运行.但是,操作前和操作后脚本不被认为是构建本身的一部分.它们的输出不属于构建日志的一部分,并且脚本失败也不会导致构建失败.

In Xcode 4+, you could run this script as a pre- or post-action script on the "Archive" action. However, pre- and post-action scripts are not considered part of the build itself; their output is not part of the build log, and a failing script will not cause the build to fail.

如果要将此脚本作为构建的一流部分包括在内,以致于其失败将导致构建失败,那么您将需要做其他事情.创建一个新的外部构建系统"目标,并将其配置为运行脚本.脚本的路径可以是相对于项目根目录的相对路径.

If you want to include this script as a first-class part of the build, such that its failure will cause the build to fail, then you'll want to do something else. Make a new "External Build System" target, and configure it to run your script. The path to your script can be a relative path, relative to the project root.

最后,打开您的主项目方案,并在构建"标签中添加新的检查器目标,并将其设置为仅包含在归档"操作中.这应该使您的检查器脚本仅在选择存档"时才作为构建的一部分运行,并且如果脚本返回非零值,则构建将失败.

Finally, open your main project scheme, and in the "Build" tag add the new checker target, and set it to only be included in the "Archive" action. This should cause your checker script to be run as part of the build only when "Archive" is selected, and if the script returns a non-zero value the build will fail.

这篇关于仅针对Xcode 4中的“存档"构建运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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