Run script during Clean / Clean All in Xcode

别说谁变了你拦得住时间么 提交于 2019-12-12 10:36:23

问题


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.

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?


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.

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.


回答1:


You can try to Add > New Target… > Shell Script Target by control-clicking on a Targets node in the Groups & Files.

Then, after double-clicking on a Run Script node you setup any cleanup-scenario using $ACTION variable that can have values clean, install, etc.

And finally, newly created Shell Script Target should be added to the main target as dependency.




回答2:


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.



来源:https://stackoverflow.com/questions/1903890/run-script-during-clean-clean-all-in-xcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!