Xcode 9 中使用 RealmSwift 3.1.1 的多个警告

Multiple warnings using RealmSwift 3.1.1 in Xcode 9

将上述版本的 RealmSwift CocoaPod 添加到我的任何 Xcode 9.2 项目后,我收到 23 个编译器警告(见屏幕截图)。

已安装 Cocoapods 版本(1.4.0、1.3.1) RealmSwift 版本 3.1.1

具体消息内容如下:

/Users/myname/Repos/iOS Projects/My Projects/TestRealmPods/Pods/Realm/Realm/RLMArray.mm:256:10: Block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behaviour

仅当我尝试构建/运行 项目时才会出现警告。 警告仅与 RLMArray.mm & RLMManagedArray.mm 类 有关。

我尝试从以前的版本更新 CocoaPods 和 Realm 版本,但在这两种情况下都收到相同的警告。

非常感谢提供的任何帮助。

出现此警告是因为 CocoaPods 正在移动以启用 CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF 默认。我认为,此警告将在下一个 Realm 版本中修复。但作为临时解决方案,您可以将此代码添加到 Podfile 文件中以消除警告。

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF'] = false
        end
    end
end