我使用的是 Xcode 8 和 Swift 3.0。此错误消息是什么意思?
ld: warning: Some object files have incompatible Objective-C category definitions. Some category metadata may be lost. All files containing Objective-C categories should be built using the same compiler.
最佳答案
我在 UIColor
扩展中也遇到了这个问题,除了一些使用 Objective-c 的框架之外,我的应用完全是用 swift 制作的,所以我在声明 var时没有问题
作为@nonobjc
:
extension UIColor {
@nonobjc static var lol: UIColor {
return UIColor.red
}
}
来自苹果文档:
The nonobjc attribute tells the compiler to make the declaration unavailable in Objective-C code...
由于此代码对 Objective-C 不可用,因此警告消失。
关于ios - Xcode 8 Objective-C 类别警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39373386/