Xcode 4 "Clean" vs. "Clean Build Folder"
Asked Answered
S

5

90

You come at a certain point in the development of every app that what you see in the simulator does not match what you think should happen. Mostly these are human errors -- or at least they are in most of my cases ;-) -- but sometimes Xcode has just 'lost track', or so it seems. I've learnt that the Clean (Shift+Cmd+K) and Clean Build Folder… (Option+Shift+Command+K) menu options can show the difference between your error or Xcode's.

My question though is:

What does the Clean command do or not do, which leaves a reason for Clean Build Folder… to exist? When should I pick one over the other, why not just always clean the whole folder?

Selle answered 10/11, 2011 at 22:10 Comment(2)
You may find some answers in this potentially duplicate question.Hedveh
There might be some hidden clues there, but it's totally not a duplicate question. Mine is about the differences between clean and clean build folder, two very similar looking commands. But thanks for the heads up.Selle
P
97

Clean… cleans the folders for the current selected target.
Clean Build Folder… cleans the folders for all the targets.

Piracy answered 10/11, 2011 at 22:58 Comment(2)
This is ambiguous with that apostrophe in "all the target's folders". Do you mean "the folders for all targets or are there some other folders associated with the selected target?Halsy
This answer is not complete. Clean Build Folder solves problems in projects with only a single target.Fairhaired
B
99

If you select Clean from the Product menu, XCode will delete the files inside every folder in the Build folder, if you select Clean Build Folder it will delete the entire Build folder.

After Clean command:

enter image description here After Clean Build Folder command:

enter image description here

I think you should select Clean Build Folder when you want to build a binary that you want to release to the AppStore, when you messed up with your project or when your app doesn't work for an "unknown" reason, otherwise use Clean.

I hope I've answered your question :D

Barahona answered 10/11, 2011 at 23:8 Comment(5)
Sorry to be skeptical, but this seems odd. Are you saying the only difference between the two is that one deletes the folders and the other keeps the folders but deletes all the contents? What would be the difference in having four empty folders? Yet there is a noticeable difference between cleaning and sometimes having to clean build folders...Battery
Yes, that's the only difference. Personally I use "Clean" before building an app for the iOS Simulator or when I have strange problems with code and/or XCode and "Clean Build Folder" when I want to publish an app to the App Store or when I want to be sure that my app is build from the ground up with no caches.Barahona
Is it just me, or 'Clean Build Folder' is faster than 'Clean'?Cleft
Something has changed for Xcode 8, Build folder is kept after Clean Build Folder.... Obviously, Clean Build Folder... is more complete than Clean. However, I think deletion of ~/Library/Developer/Xcode/DerivedData/xxx-ABCD folder is needed in some case such as your Xcode cannot work properly, where xxx is the name of your project or workspace.Cretan
Always love when people come back to an old question and answer thats popular and make a very clear example and explanationReign
P
97

Clean… cleans the folders for the current selected target.
Clean Build Folder… cleans the folders for all the targets.

Piracy answered 10/11, 2011 at 22:58 Comment(2)
This is ambiguous with that apostrophe in "all the target's folders". Do you mean "the folders for all targets or are there some other folders associated with the selected target?Halsy
This answer is not complete. Clean Build Folder solves problems in projects with only a single target.Fairhaired
S
12

As of Xcode 10, 'Clean' has effectively disappeared. Apple says here:

"The new build system uses the "clean build folder" behavior. The legacy "clean" behavior is not supported".

Shaia answered 6/6, 2019 at 15:1 Comment(0)
W
4

If you select "Clean", Xcode will delete files inside every folder(e.g., Products, Intermediates) in the Build folder, for the current target. Files for other targets remain.

If you select "Clean Build Folder", Xcode will delete the entire Build Folder, so nothing left.

In most cases "Clean" will work for "unknown" reasons, but you still have to "Clean the Build Folder" because Xcode won't delete files in the include folder inside Products folder.

Wiltshire answered 5/9, 2014 at 3:13 Comment(0)
C
0

Some files at ~/Library/Developer/Xcode/DerivedData/xxx-ABCD, where xxx is the name of your project or workspace, have been deleted after you Clean or Clean Build Folder.... Obviously, Clean Build Folder... will delete more files than Clean will do. However, I think deletion of the folder that I mentioned before is needed in some case, such as your Xcode cannot work properly.

By the way, something has changed for Xcode 8, Build folder is kept all the same after Clean Build Folder...

Cretan answered 6/9, 2017 at 12:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.