简体   繁体   English

在Xcode的Clean / Clean All中运行脚本

[英]Run script during Clean / Clean All in Xcode

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. 我有一个相当复杂的(iPhone SDK)Xcode项目,其中有许多目标-4个静态库,单元测试,多个示例应用程序,运行Shell脚本的BuildAll和运行另一个Shell脚本的Package。 The "BuildAll" target creates a directory in the project with some subdirectories with contents ready for distribution. “ BuildAll”目标在项目中创建一个目录,其中包含一些子目录,这些目录准备好分发。

When I click "Clean All," though, Xcode doesn't know to clean my Distribution directory. 但是,当我单击“全部清除”时,Xcode不知道要清除我的分发目录。 I'd like it to. 我想要。 I can't seem to find a way to do this -- does anybody know how? 我似乎找不到解决方法,有人知道吗?


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. 感觉Clean and Clean All实际上应该只是Xcode中的目标,并且我应该能够添加“运行脚本”阶段。 Not so, to my knowledge. 据我所知并非如此。

BTW, the "BuildAll" target does handle cleaning the Distribution directory, so this is not the end of the world to me. 顺便说一句,“ BuildAll”目标确实可以清理分发目录,所以这对我来说不是世界末日。 It's just irksome that "Clean All" doesn't actually clean all in my particular case. 在我的特定情况下,“全部清除”实际上并没有全部清除,这真是令人讨厌。

You can try to Add > New Target… > Shell Script Target by control-clicking on a Targets node in the Groups & Files. 您可以通过按住 Control键并单击“组和文件”中的“ 目标”节点来尝试添加>新目标…> Shell脚本目标

Then, after double-clicking on a Run Script node you setup any cleanup-scenario using $ACTION variable that can have values clean , install , etc. 然后,在“运行脚本”节点上双击后,您可以使用$ ACTION变量设置任何清理场景,该变量的值可以为cleaninstall等。

And finally, newly created Shell Script Target should be added to the main target as dependency. 最后,应将新创建的Shell脚本目标作为依赖项添加到主目标。

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环境变量检查操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM