Could not build module UIKit

别等时光非礼了梦想. 提交于 2019-11-30 07:45:23

问题


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.


回答1:


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.




回答2:


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




回答3:


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




回答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.




回答5:


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

You have 2 solutions:

1. Just Re-install XCode.

OR

2. Copy the Framework from another Mac (with same XCode version) & paste into yours.

Location:

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



回答6:


If you have two Xcode then uninstall both and again install Xcode.it works for me.




回答7:


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 Hope that this will help.




回答8:


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

Click to select simulator

Select Generic iOS Device




回答9:


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




回答10:


Cleaning Derived data worked for me




回答11:


Cleaning the project and restart xCode worked for me.




回答12:


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.




回答13:


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.




回答14:


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.




回答15:


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.




回答16:


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!




回答17:


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.




回答18:


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.




回答19:


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




回答20:


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




回答21:


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.




回答22:


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.




回答23:


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



来源:https://stackoverflow.com/questions/20163812/could-not-build-module-uikit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!