Reputation: 1693
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
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
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
Reputation: 173
I had the same problem when my Mac's storage was full. You should check your available storage.
Upvotes: 1
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
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
Select "Generic iOS Device":
Upvotes: 3
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
Reputation: 1956
If you have two Xcode then uninstall both and again install Xcode. It worked for me.
Upvotes: 5
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
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
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
Reputation: 987
Cleaning some unnecessary Xcode data using DevCleaner for Xcode app worked for me.
Upvotes: 0
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
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
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
Reputation: 1568
Make sure none of the files are edited in the UIKit
framework located inside Xcode.
Upvotes: 2
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
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
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
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
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
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
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
Reputation: 3183
Something that might help would be to set the Derived Data location to "Relative" in XCode preferences, then Clean & Build
Upvotes: 12