快速使用UIDevice类时出现以下构建错误。
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1Global 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
}

最佳答案

您还在某处使用UI_USER_INTERFACE_IDIOM()吗?如果是这样,请尝试改用UIDevice.currentDevice().userInterfaceIdiom

关于ios - Swift UIDevice构建错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35888309/

10-13 03:00