Xcode 4“ Clean”vs“ Clean Build Folder”

在每个应用程序开发的某个阶段,你在模拟器中看到的东西与你认为应该发生的事情并不相符。大多数情况下,这些都是人为的错误——或者至少在大多数 天啊案例中是这样; ——但有时候,Xcode 只是“迷失了方向”,至少看起来是这样。我了解到,Clean(Shift + Cmd + K)和 Clean Build Folder…(Option + Shift + Command + K)菜单选项可以显示您的错误或 Xcode 的错误之间的区别。

我的问题是:

Clean命令做什么或不做什么,这就给 Clean Build Folder…留下了存在的理由?什么时候我应该选择其中一个,为什么不总是清理整个文件夹?

41460 次浏览

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

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

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.

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

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