Xcode 8 Objective-C category warning

后端 未结 8 1184
生来不讨喜
生来不讨喜 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:32

    This warning appeared in my project after adding a framework that used Objective-C in my application that otherwise used Swift 3 entirely.

    By declaring all static functions and static variables in all extensions as @nonobjc this warning went away.

    For example

    extension Notification.Name {
        @nonobjc static let MyNotificationName = Notification.Name("NNSongFavoriteStatusDidChangeNotification")
    }
    

    or

    extension UIColor {
        @nonobjc static let superGiantRed = UIColor(red: 180.0/255.0, green: 40.0/255.0, blue: 27.0/255.0, alpha: 1.0)
    }
    

提交回复
热议问题