Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 8 Objective-C category warning

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 definitions. Some category metadata may be lost. All files containing Objective-C categories should be built using the same compiler.

like image 910
jherg Avatar asked Sep 23 '16 16:09

jherg


1 Answers

I also had this issue in a UIColor extension, my app is entirely made with swift except for some frameworks that use Objective-c so I have no problem in declaring the var as @nonobjc:

extension UIColor {    @nonobjc static var lol: UIColor {       return UIColor.red    } } 

From the apple docs:

The nonobjc attribute tells the compiler to make the declaration unavailable in Objective-C code...

Since this code is unavailable to Objective-C the warning disappears.

like image 55
juanjo Avatar answered Sep 21 '22 05:09

juanjo