使用UIDevice类时,我会得到以下生成错误。
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!
触发错误的代码是print(UIDevice.currentDevice())。
我是做错什么了,还是有人知道解决办法?
是的,我已经导入了UIKit :)
*编辑*
下面是我使用的函数,注意注释掉的UIDevice引用修复了构建错误
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
}发布于 2016-03-09 10:20:09
您是否也在某个地方使用UI_USER_INTERFACE_IDIOM()?如果是的话,尝试使用UIDevice.currentDevice().userInterfaceIdiom代替。
https://stackoverflow.com/questions/35888309
复制相似问题