Could not build module UIKit Could not build module UIKit ios ios

Could not build module UIKit

Please don't make the same mistake like I did. In my case, I accidentally typed some words into Foundation framework file.

A full clean + deleting the derived data worked for me.

Be sure to fix any code that may be broken because UIKit cannot be installed, before the clean and build.

So, for example, if you are trying to reference UICollectionViewController, and need UIKit to reference it, comment out the code that is using UICollectionViewController, comment out the import for UIKit.

Then clean, build. Now uncomment import UIKIt, build. NOW uncomment UICollectionViewController code, build again.

Something that might help would be to set the Derived Data location to "Relative" in XCode preferences, then Clean & Build

XCode derived data location