Could not build module UIKit

38,737

Solution 1

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

Solution 2

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.

Solution 3

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

XCode derived data location

Solution 4

For some reason your UIKit.framework is corrupted, either copy a working UIKit.framework from somewhere else into

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks

Or reinstall Xcode the fix the issue.

Solution 5

I accidentally edited the Foundation framework file so UIKit.framework got corrupted. The only solution is recover the original.

You have two solutions: Just reinstall XCode or copy the Framework from another machine with the same XCode version and paste into yours.

Location:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks
Share:
38,737
Hardik Shah
Author by

Hardik Shah

Updated on March 03, 2020

Comments

  • Hardik Shah
    Hardik Shah over 4 years

    Suddenly it stops building application in device. In simulator its working but when I connect the device and try to run it in device it gives me an error:

    Could not build module UIKit

    I tries a lot but couldn't solve it.