Reputation: 568
I'm trying to set all my colours in one Swift file that can be used throughout my application.
The following code below results in...
import Foundation
import UIKit
class DotColors {
let tsblueColor = UIColor(red:58/255.0, green: 125/255.0, blue: 208/255.0, alpha: 1.0)
}
... Expected ';' after top level declarator
Upvotes: 12
Views: 11891
Reputation: 4236
The same error occurred to me after I've added the first swift file to my objc project. That's how I fixed it:
#import "ExampleFile.swift"
but use #import "ProjectName-Swift.h"
@objc
statements in your swift code that you want to import to objcThese are the links that were helpful:
Upvotes: 8
Reputation: 353
I got this error, persisting even once i made the appropriate code changes, after accidentally selecting an OS X Source Cocoa Class in the new file prompt, instead of an iOS Source Cocoa Touch Class.
Try creating a new swift file that you're sure is kicked off as iOS.
Upvotes: 0
Reputation: 170
Try putting
import UIKit
In the top. Think that will solve your problem!
Upvotes: 0
Reputation: 3653
You forgot to import UIKit.
import UIKit
You can try this,
import Foundation
import UIKit
class DotColors {
let tsblueColor = UIColor(red:58/255.0, green: 125/255.0, blue: 208/255.0, alpha: 1.0)
}
Upvotes: 2