Xcode 8 Objective-C category warning

后端 未结 8 1202
生来不讨喜
生来不讨喜 2020-12-05 09:13

I\'m using Xcode 8 and Swift 3.0. What does this error message mean?

ld: warning: Some object files have incompatible Objective-C category definition

8条回答
  •  没有蜡笔的小新
    2020-12-05 09:48

    In my case, the reason was having computed type property in an extension:

    extension NSParagraphStyle {
        class var defaultStyle: NSParagraphStyle {
            return ...
        }
    }
    

    Not sure what the exact reason behind this is, but to get rid of the warning I had to convert the computed type property (class var) to a type method (class func):

    extension NSParagraphStyle {
        class func defaultStyle() -> NSParagraphStyle {
            return ...
        }
    }
    

提交回复
热议问题