Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clean project before each build?

Tags:

xcode

Is there a way (possibly using schemes) in Xcode to specify that a clean is automatically done before doing a new build.?

I have a project that sometimes fails to build unless I do a clean first, currently I am doing it by hand.

like image 932
fuzzygoat Avatar asked Sep 08 '11 13:09

fuzzygoat


People also ask

How do you clean a project?

Manually delete the [project]/. gradle as hidden folder as that one is the main culprit for large cleaned projects sizes. and don't forget to manually delete the [project]/. gradle hidden folder as that one is the main culprit for large cleaned projects sizes.

How do you clean and build a project?

On the menu bar, choose Build, and then choose either Build ProjectName or Rebuild ProjectName. Choose Build ProjectName to build only those project components that have changed since the most recent build. Choose Rebuild ProjectName to "clean" the project and then build the project files and all project components.

How do you do a clean build?

To build, rebuild, or clean an entire solution Choose Rebuild All to "clean" the solution and then builds all project files and components. Choose Clean All to delete any intermediate and output files. With only the project and component files left, new instances of the intermediate and output files can then be built.

What is the difference between build rebuild and clean?

Build solution: Compiles code files (DLL and EXE) which are changed. Rebuild: Deletes all compiled files and compiles them again irrespective if the code has changed or not. Clean solution: Deletes all compiled files (DLL and EXE file).


2 Answers

Press ⌥⌘R, expand the selected scheme, select Pre-actions, click +, select New Run Script Action, set Provide Build Settings from to your target. In the box below type rm -rf ${BUILT_PRODUCTS_DIR}. Note: it is BUILT not BUILD as seen in the Xcode dialog. You can type echo ${BUILT_PRODUCTS_DIR} > ~/Desktop/log.txt to see what's going to be deleted.

like image 143
Jano Avatar answered Oct 13 '22 20:10

Jano


The selected answer did not work for me, it caused my build to fail (Xcode 4.6.3) when trying to run on the simulator.
Based on Jano'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 cause my build to fail

like image 21
keisar Avatar answered Oct 13 '22 20:10

keisar