views:

517

answers:

2

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  A: 

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.

Stream
Is the "Shell Script Target" different from an empty target with a "Shell Script Build Phase"? I've added Build Phases to my app targets and checked the $ACTION environment variable, but it seems like Xcode doesn't run the script at all on clean.
benzado
Yes, it looks like Targets and Build Phases have different workflows when Xcode project is being built.
Stream
A: 

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.

miguel