Can't solve "Could not build module "UIKit" - ios

On the way to develop iOS app in Objective-C and writing some code, Suddenly the error "Could not build module "UIKit" appeared.
Opening the other Xcode project, same error caused.
(Xcode version is 7.3)
I have done them
・Clean(Cmd + K)
・Clean Build Folder
・Delete DerivedData
・Remove and add UIKit.framework
・Set the "Allow Non-modular Includes in Framework modules" setting to YES
How can I solve it?

The command rm -rf ~/Library/Developer/Xcode/DerivedData/* to clear cache thoroghly solved my problem.

Import #import in every class where you are getting error.

Try creating some demo project and check if same error coming in new project?
and if the error remain same then you will need to uninstall the Xcode and re-install it.

Setting Framework Search Paths miscorrect causes the same error. Check your Framework Search Paths and be sure it's setup correctly.

try To import UIKit in UIColor.h class and other classes where it require, in my case i have solved with this single line.
#import <UIKit/UIKit.h>
if you still face issue so please let me know.

Related

symbol(s) not found for architecture arm64

Facing ObjC file reference issue. I tried pod deintegration, removing DerivedData, Cleaning the project, Adding -Objc and $(inherited) FLAGS.
I am using cocoapods, Xcode 9, Swift 4. Please revert if anyone have resolved this issue.
I had same issue make your your ".m" implementation files are assigned to the Target Membership:
For me none of these answers worked, and appeared to cause more problems.
My solution was in terminal trying "pod install" It added a missing file for me and everything was good to go
Try this
Goto Project -> Build setting
Serach enable bitcode & set it to NO
Check for the AppDelegate and OnBoardingViewCtontroller file in your project.
Just delete to and add it again. When your are adding it again make sure that Copy If needed option is checked
This is bcoz if your uncheck this check box then the file reference is created and if you move project the you will get this error.
Check Your Pod file that is it targeting your App Target?.
May be Pod is not targeting your App Target.
This error occurs when you have reference of File or Framework that is not included in Target.
change the Build Configuration from Debug to Release.
Edit Scheme... -> Info -> Run -> Build Configuration
Try Build Active Architecture Only to NO:
You need to add necessary framework to your project. Check all third party party framework and search its required framework for support. For e.g. if you add google analytic then you need to add CoreData , Foundation etc framework. There is some framework is missing for which third party framework needs.
Or you can-
Press "Cmd+Shift+K" to clean up, and quit Xcode.
Delete the cache Run "rm -rf ~/Library/Developer/Xcode/DerivedData"
in terminal
Open the project and re-build it
Hope this will solve your problem.
Pods for UITest and Test projects for the pods was causing the issue. Check for it.
Check if there are certain function which are declared in .h file but are not implemented in implementation file and they are being called from another class.
It should be -ObjC, not -Objc. Note the upper case C.

Cyclic dependency in module 'Darwin': in XCode 9.2

Getting this weird error suddenly.
I have tried cleaning and deleting the derived data and also tried changing the Enable modules flag in build settings.
Does anyone know how to fix this errors in Xcode.
EDIT: The errors only show up while archiving, I can successfully build and run in Simulator.
It can be easily reproduced by just installing Core plot and Google speech api together via Cocoapods.
Had the same issue, fixed by replacing #import <CommonCrypto/CommonCrypto.h> with #import <CommonCrypto/CommonHMAC.h> in my Swift bridging header file. The former includes CommonKeyDerivation.h, which eventually include time.h. However, gRPC has a time.h file as well, as it has header priority in header search path, its timer.h version is used instead of the system one, which caused to the issue you mentioned. Hope this helps.

Cannot load underlying module for 'Charts'

I'm just getting started with the iOS charts library :
I followed all the steps described under 'Usage' on the main page (https://github.com/danielgindi/ios-charts):
I added a UIView and made it subclass LineChartView
--> in ViewController.swift: the line import Charts gives an error: Cannot load underlying module for 'Charts'
Why is that ?
Thank you !
It's possibly related to this issue too: https://github.com/Alamofire/Alamofire/issues/122
In short: Seems like there's a bug in Xcode 6.3.1, where new projects have problems when importing Embedded Frameworks. In such a case, you need to let the project build first, and then add the framework to the project.
Sounds like your project haven't added the framework successfully. I just started with ios-charts as well, and I followed the steps on github as well and it worked like a charm. What I did was to just drag the Charts.xcodeproj into my Project Navigator and it worked like a charm. If this doesn't work for you, however, make sure you are using iOS 8. If you are not, then you have to add the .swift-files to your project. If you are using iOS 8 and the approach still doesn't work, I'd try to install it using CocoaPods instead. I'm fairly new in CocoaPods so can't really help you there, but just google on how to install frameworks using CocoaPods and you should find what you seek.
Sorry if I wasn't of much help!
The answer comes a bit late, but what solved the problem for me was to clean my project by selecting the option Product > Clean from my status bar. Hope it might help someone else in case you solved the problem already.
After cleaning the product once I received this error. I then removed the framework from embedded binaries, cleaned the product, then added it once more to embedded libraries. I then built the product and retried the import statement. The import statement worked.
I had the same issue with KeychainAccess pod. Even though the pod was installed it use to throw an error
‘Cannot load underlying module for KeychainAccess’.
The fix that worked for me :
Uninstall the pod and install it again
Delete the derived data content
Quit Xcode and start again
Make sure your scheme is targeting an iOS device or simulator. If you build for your Mac it'll give you this error.
Build the project and this error will go away

Adding FacebookSDK

I drag/drop facebooksdk.framework to my project(and i select copy items). I complete coded part and when i run my project it worked without any problem.
However when i close xCode and start xCode and run my project x code gives red error messages. Its;
"/Users/me/Desktop/xcode/swift/projects/projects/projects/projects-Bridging-Header.h:6:9: 'FacebookSDK/FacebookSDK.h' file not found"
and other one is;
"Failed to import bridging header '/Users/me/Desktop/xcode/swift/projects/projects/projects/projects-Bridging-Header.h'
The problem solved by re-added facebooksdk.framework file to my project. Did i have to always add this framework to my project(everytime i start this project xcode gives red errors)? Is there any way to fix that?
Thank you.
You need to import your facebooksdk.framework like this one inside projects-Bridging-Header.h
#import <FacebookSDK/FacebookSDK.h>

Objective C - Precompiled Headers Creating Error

Hi i am importing some classes in .pch file it is working fine. I can build and run too but when those classes that are included in .pch file are accessed complier gives error but still it an build successfully and run the program too. But as soon as i again import them in some class then complier doesn't gives any error. What is the problem that is causing this?
Edit: I tried Cleaning Project and build folder but no effect
I solved this problem by quoting Xcode forcefully and by going to finder->Gotofolder
~/library/developer/xcode/deriveddata
and deleting everything and when i tried running again i was not prompted any error
if you add the three lines under Search Paths->Framework Search Paths as mentioned below
$(inherited)
$(SRCROOT)
"$(SRCROOT)/frameworkname"
I think the problem is Complier not able to locate the framework.
Hope this will help

Resources