How to clean the project before each assembly?

Is there a way (possibly using schemas) in Xcode to indicate that a cleanup is automatically performed before a new build is executed.?

I have a project that sometimes cannot be built if I do not do the cleaning first, currently I do it manually.

+9
source share
2 answers

Press ⌥⌘R, expand the highlighted diagram, select "Preliminary Actions", press "+", select "New Launch" Script Action, set "Provide Assembly Parameters" to your target. In the box below, enter rm -rf ${BUILT_PRODUCTS_DIR} . Note: it DOES NOT BUILD, as shown in the Xcode dialog box. You can enter echo ${BUILT_PRODUCTS_DIR} > ~/Desktop/log.txt to see what will be deleted.

+22
source

The selected answer did not work for me, it made my assembly crash (Xcode 4.6.3) when trying to run on the simulator.
Based on Yano's answer and on this link in the Pre-action script instead of writing

 rm -rf ${BUILT_PRODUCTS_DIR} 

I wrote

 touch ${BUILT_PRODUCTS_DIR} 

This should have the same effect, and it doesn't crash my build

+2
source

All Articles