Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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.

like image 268
jibberia Avatar asked Dec 14 '09 22:12

jibberia


2 Answers

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.

like image 136
Vadim Avatar answered Sep 20 '22 03:09

Vadim


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.

like image 42
miguel Avatar answered Sep 22 '22 03:09

miguel