Reputation: 63
I'm getting this really weird error when trying to import UIKit in my swift file.
My Code is simply:
import UIKit
class Test: NSObject {
}
The error I get at 'import UIKit' is:
I have added UIKit to my Frameworks folder, the class doesn't contain any code (so therefore there shouldn't be anything wrong with it) and I tried to restart both xCode and my Mac, but the error is still there.
I appreciate any help.
Thanks.
EDIT: Solved:
I tried to import 'Test.swift' in AppDelegate.
Upvotes: 6
Views: 9843
Reputation: 3405
In my case, it was because somehow the selected type in the file inspector was objective-c source instead of Default - Swift Source even though i was using a .swift file.
Changing it to Default - Swift Source solved the issue for me.
Upvotes: 0
Reputation: 14145
The import stuff in swift is case sensitive. Example :
import uikit
will not work. You'll have to type it as
import UIKit
Upvotes: 0
Reputation: 1503
This problem usually happens when you try to import ".swift" file in your Objective-C code, like this: #import "HomeViewController.swift"
. This is wrong and you should import special, automatically generated Swift header, instead:
#import "ProductModuleName-Swift.h"
where ProductModuleName
is the name of your module (or project) containing the Swift code.
Upvotes: 25
Reputation: 1484
Found good Trouble shooting guide - there is great Troubleshooting Tips and Reminders section!
Upvotes: 1