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 扩展中也遇到了这个问题,除了一些使用 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/

相关文章:

ios - 滚动关闭和打开后, View 重新出现在 UITableViewCell 中

objective-c - 在内容为通过特定对象属性获取 Core Data 对象的 NSArray 中搜索

ios - 按其中一个键内的值对 NSDictionaries 数组进行排序

ios - iOS SDK 是否带有艺术作品/图标库?

ios - 如果 dispatch_sync 不使用不同的线程,它会更快吗?

iphone - 为了避免苹果拒绝,我的应用程序最重要的是什么?

来自其他类的SwiftUI调用函数

ios - Xcode 7.0.1 - 无效的 Swift 支持 - 缺少 SwiftSupport 文件夹。

ios - 将引用存储在变量 SWIFT 4 中

ios - XCode FacebookSDK 框架搜索路径