在 Xcode 中的 Clean / Clean All 期间运行脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1903890/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Run script during Clean / Clean All in Xcode
提问by jibberia
I have a fairly complex (iPhone SDK) Xcode project, with many targets -- 4 static libs, unit tests, multiple sample apps, a BuildAll that runs a shell script, and a Package that runs another shell script. The "BuildAll" target creates a directory in the project with some subdirectories with contents ready for distribution.
我有一个相当复杂的(iPhone SDK)Xcode 项目,有很多目标——4 个静态库、单元测试、多个示例应用程序、一个运行 shell 脚本的 BuildAll 和一个运行另一个 shell 脚本的包。“BuildAll”目标在项目中创建一个目录,其中包含一些准备分发内容的子目录。
When I click "Clean All," though, Xcode doesn't know to clean my Distribution directory. I'd like it to. I can't seem to find a way to do this -- does anybody know how?
但是,当我单击“全部清除”时,Xcode 不知道要清除我的分发目录。我愿意 我似乎找不到办法做到这一点——有人知道怎么做吗?
It feels like Clean and Clean All should really just be targets in Xcode, and I should be able to add a "Run Script" phase. Not so, to my knowledge.
感觉 Clean 和 Clean All 真的应该只是 Xcode 中的目标,我应该能够添加一个“运行脚本”阶段。不是这样,据我所知。
BTW, the "BuildAll" target does handle cleaning the Distribution directory, so this is not the end of the world to me. It's just irksome that "Clean All" doesn't actually clean all in my particular case.
顺便说一句,“BuildAll”目标确实处理清理分发目录,所以这对我来说不是世界末日。在我的特定情况下,“全部清除”实际上并不能全部清除,这令人讨厌。
回答by Vadim
You can try to Add > New Target… > Shell Script Targetby control-clicking on a Targetsnode in the Groups & Files.
您可以尝试通过在 Groups & Files 中的Targets节点上按住Control 键单击Add > New Target... > Shell Script Target。
Then, after double-clicking on a Run Scriptnode you setup any cleanup-scenario using $ACTION variable that can have values clean, install, etc.
然后,双击运行脚本节点后,您可以使用 $ACTION 变量设置任何清理场景,该变量可以具有clean、install等值。
And finally, newly created Shell Script Targetshould be added to the main target as dependency.
最后,应将新创建的Shell Script Target作为依赖项添加到主目标中。
回答by miguel
You can add an "External Target" that does the cleaning in an external script, and add that target as a dependency of one of your static library targets. Create the target, and drag it under one of your static library targets. Check for the action using the $ACTION environment variable in the script.
您可以添加一个在外部脚本中进行清理的“外部目标”,并将该目标添加为您的静态库目标之一的依赖项。创建目标,并将其拖到您的静态库目标之一下。使用脚本中的 $ACTION 环境变量检查操作。