Reputation: 1613
I get the following build error when using the UIDevice class in swift.
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
Global variable initializer type does not match global variable type!
%struct._class_t** @"OBJC_CLASSLIST_REFERENCES_$_"
LLVM ERROR: Broken module found, compilation aborted!
The code that triggers the error is simply print(UIDevice.currentDevice())
Am I doing something wrong, or does anyone know a workaround?
And yes i've imported UIKit :)
* Edit *
Here is the function i'm using, note that commenting out the UIDevice reference fixes the build error
func setAFHTTPRequestOperationManager(manager : AFHTTPRequestOperationManager) {
manager.responseSerializer = AFJSONResponseSerializer()
manager.requestSerializer = AFHTTPRequestSerializer()
// This causes compile issue?
uuid = (UIDevice.currentDevice().identifierForVendor?.UUIDString)!
manager.requestSerializer.setValue(uuid, forKey: K.API.HeaderFields.DeviceToken)
var types = NSSet()
types = manager.responseSerializer.acceptableContentTypes
types = types.setByAddingObject(K.API.HeaderFields.TextContentType)
manager.responseSerializer.acceptableContentTypes = types as Set<NSObject>
manager.requestSerializer.timeoutInterval = 30
manager.requestSerializer.cachePolicy = NSURLRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData
afNetworkingManager = manager
}
Upvotes: 2
Views: 700
Reputation: 11
Are you also using UI_USER_INTERFACE_IDIOM()
somewhere? If so, try using UIDevice.currentDevice().userInterfaceIdiom
instead.
Upvotes: 1