ios - Xcode 8 Objective-C 类别警告

标签 ios objective-c swift xcode xcode8

我正在使用 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 扩展中也遇到了这个问题,我的应用程序完全是用 swift 制作的,除了一些使用 Objective-c 的框架,所以我在声明 var as @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/39665979/

相关文章:

ios - 我应该在 firebase 中使用查询还是使用 observe 函数?

ios - Realm - 对象中的对象列表(Swift 3)

ios - MKMapView隐藏 basemap 图层

iphone - UITableView 滚动时重复单元格

swift - “ fatal error :在展开可选值时意外发现nil”是什么意思?

ios - Alamofire 不执行该 URL

ios - GMSGroundOverlay 动画 - 我应该使用 CATiledLayer 吗?

ios - 从 itunes.apple.com/lookup 查找 "App Bundle"

ios - UITableViewCell - 接收 Stepper 实例值

swift - 在结构中创建 UIButton