XCode caches build errors too aggressively

Since XCode 9, I've been seeing build errors hang around after they're fixed. It's very annoying because they obscure actual build errors.


For example, a cocoapod was not in the right place, so the import statement was flagged. I fixed the dependency, ran the app, it ran fine, but the build error persisted for several more runs until I ran in a different simulator.


Cleaning the build folder (even with OPTION key)did not help.


Is there some other way to clear build errors?

Post not yet marked as solved Up vote post of sharp11 Down vote post of sharp11
5.1k views

Replies

Same-only-different from an option-clean build folder is to do a 'delete derived data' on that build folder. Using Xcode prefs/locations will show that main location in the finder - you'll need to id the last build and **** it out from there.


'option-clean' wipes the folder itself, 'clean' wipes data for the target only, but has never made any difference for me...note that with the new build system, option-clean is now the default and clean is, thankfully, gone.


In some cases, it can help to delete all versions of the app you're working on from the simulator/device, before going again...after a jolt from an option-clean, of course.


If you think indexing is contributing to the issue, supposedly you can disable it via terminal (1 is disable, 0 is enable):


defaults write com.apple.dt.XCode IDEIndexDisable 1


- may require you to restart Xcode for it to take. Disabling will take away search and autocomplete, tho, so...

Pretty often I had to clean the build folder, quit XCode and reopen. Usually, that "flushed the caches" and solved the problem.

Looks like CBF in Xcode 9.2 had a bug. Just found this in the Xcode v9.3 beta release notes:


“Fixed an issue in which the Clean Build Folder command could fail to complete."

4 years later, it only gets worse...

Still happening with Xcode 14.3. Very annoying.

This is a classic XCode bug, still happening with XCode 15.1.

The only way I have found to fix it is to delete derived data