Hardik Shah
Hardik Shah

Reputation: 1693

Could not build module UIKit

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.

Upvotes: 38

Views: 47681

Answers (27)

Mahsa
Mahsa

Reputation: 11

removing 'use_modualar_headers!' at top of my podfile solved the issue for me after hours of searching for a solution.

Upvotes: 1

Valentina Varela
Valentina Varela

Reputation: 19

In my case, my app is on React Native, and the problem was due to Firebase/app. I had to delete the dependency on React Native, run npm i, modify Podfile to comment out the references to Firebase related pods that apparently only work if you use modular headers run: pod cache clean --all and pod install to remove the dependencies and the error disappeared.

The thing it seemed to be, that using those modular headers somehow "brakes" the UIKit, resulting on several errors.

For now I was using Firebase to distribute, but I'm very disappointed because I wanted to implement push notifications using Firebase, and I haven't found anyone that could implement it successfully on iOS, so I'm investigating other options, as Codepush.

Upvotes: 0

Md. Mahede hasan
Md. Mahede hasan

Reputation: 173

I had the same problem when my Mac's storage was full. You should check your available storage.

Upvotes: 1

Lal Krishna
Lal Krishna

Reputation: 16180

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

You have two ways to achieve the same:

  • 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

Upvotes: 8

Sazzad Hissain Khan
Sazzad Hissain Khan

Reputation: 40237

Check whether the appropriate target is selected or not from the "active scheme selector". Selecting "Generic iOS Device" solved my problem.

Click to select simulator

enter image description here

Select "Generic iOS Device":

enter image description here

Upvotes: 3

Yedidya Reiss
Yedidya Reiss

Reputation: 5326

If cleaning the project and deleting the 'derived data' doesn't work, try to change the 'Deployment target' (at 'General' tab) from 7.0 to 7.1

Upvotes: 3

vikas prajapati
vikas prajapati

Reputation: 1956

If you have two Xcode then uninstall both and again install Xcode. It worked for me.

Upvotes: 5

tamir007
tamir007

Reputation: 178

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.

Upvotes: 9

chinnawatp
chinnawatp

Reputation: 1530

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

Upvotes: 24

Declan Land
Declan Land

Reputation: 650

My error was a wrong version of command line tools - go to Preferences->Locations and change the command line tools version - quit xcode and try again.

Upvotes: 0

Nazariy Vlizlo
Nazariy Vlizlo

Reputation: 987

Cleaning some unnecessary Xcode data using DevCleaner for Xcode app worked for me.

Upvotes: 0

Fa.Shapouri
Fa.Shapouri

Reputation: 1048

I had this issue, and I set Device on Generic iOS Device, clean project, make build. Then I switched device to my real device and run project. The error does not appear.

Upvotes: 1

Eddie.Power_AU
Eddie.Power_AU

Reputation: 1

My Issue causing this same error was due to working in a workspace created by coco pods, somehow the link to the UiKit Framework had been lost from the original project.

To solve this i just reopened the xCode project not the workspace and re added the missing UIKit framework, saved the project and closed it, re opened my workspace for the project and the annoying nag messages caused by this were fixed. Hopefully this helps someone else.

Upvotes: 0

Ely
Ely

Reputation: 9141

In my case, after cleaning the project, only restarting my Mac helps.

Upvotes: 1

jawad
jawad

Reputation: 825

It worked for me after remove all folders in DerivedData folder.

Upvotes: 0

Max
Max

Reputation: 5942

Check the tool chains installed and select the right xcode tool chain. In my case i changed it from Swift 4.0 to xcode 9.2 and it worked.

Upvotes: 1

psobko
psobko

Reputation: 1568

Make sure none of the files are edited in the UIKit framework located inside Xcode.

Upvotes: 2

Raphael Oliveira
Raphael Oliveira

Reputation: 7841

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.

Upvotes: 24

Thomas Elliot
Thomas Elliot

Reputation: 669

If your project builds for another target (e.g. it builds for simulator and NOT your device), then it's confirmed you accidentally edited one of the header files of the frameworks for that target. The affected framework is the one you are receiving compiling errors for.

Upvotes: 0

jongsky
jongsky

Reputation: 1

This error happened to me when I accidentally modified the uikit framework. Removing and re-adding the uikit framework in link binary with library, cleaning derived data and restarting xcode didn't work. I don't want to uninstall my xcode so I tried to copy codes of the class that I might have modified from other pc with xcode that works fine and paste it to mine. It worked!

Upvotes: 0

saurabh rathod
saurabh rathod

Reputation: 1278

I tried with delete derived data,delete application from project list but when i delete xcode and install new one its working so its best way just delete xcode and install new xcode.

Upvotes: 0

hsafarya
hsafarya

Reputation: 1053

Cleaning Derived data worked for me

Upvotes: 1

Dsh
Dsh

Reputation: 228

Suppose you have changed or deleted anything in the UIKit framework, then shows this error.

If you are able to find that class or .h file to be changed or deleted, then replace that whole file content in that .h file from other system's Xcode (confirm that should be similar Xcode version).

For example, In UIView.h file - I have deleted a method and closed and opened the Xcode. Then I couldn't reverted that code.

Upvotes: 0

Ezfen Zhang
Ezfen Zhang

Reputation: 1

Already tried all the solutions above. I still could not solve my problem. So I uninstall the Xcode and reinstall it. It worked magically.hope this helps.

Upvotes: 0

Waris Shams
Waris Shams

Reputation: 1614

I am also facing this issue for very long time and after trying all the suggestions given in the different portals, i came to know that the issue is with the device you want to run the application. Device have latest iOS and your Xcode is not supporting that iOS.

For example you have Xcode 7.2 and want to run the application on device which have iOS 9.2.1. So you only need to update your Xcode.

And one more thing Base Sdk in Build Settings is always greater or equal to the software version number on your development device.

Upvotes: 0

svvoff
svvoff

Reputation: 289

Cleaning the project and restart xCode worked for me.

Upvotes: 0

abinop
abinop

Reputation: 3183

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

XCode derived data location

Upvotes: 12

Related Questions