【问题标题】:Xcode: suppressing all warnings for all external librariesXcode:禁止所有外部库的所有警告
【发布时间】:2018-03-06 20:47:39
【问题描述】:

要禁用编译器警告,我转到 Project -> Target -> Build Settings 并添加标志

-w

用于特定文件。此标志禁用文件的所有警告。

但有时此标志不起作用。

例如,当我运行测试时,我收到外部库 Nimble 的警告(所有这些文件我都用标志 -w 标记):

.../Pods/Nimble/Sources/Nimble/Matchers/MatcherProtocols.swift:15:11: 'Matcher' 已弃用:改为使用谓词 .../Pods/Nimble/Sources/Nimble/Matchers/Predicate.swift:170:22: 'Matcher' 已弃用:改为使用谓词 .../Pods/Nimble/Sources/Nimble/Matchers/AllPass.swift:22:27: 'Matcher' 已弃用:改为使用谓词 .../Pods/Nimble/Sources/Nimble/Matchers/AllPass.swift:76:21:变量 'generator' 从未变异过;考虑更改为“让”常量 .../Pods/Nimble/Sources/Nimble/Matchers/AsyncMatcherWrapper.swift:41:14: 'Matcher' 已弃用:改为用于谓词

我做错了什么以及如何摆脱对我没有影响的外部库的警告?

【问题讨论】:

  • 嘿,我留下了我的答案,如果可以的话,你能确认它是接受的答案吗?

标签: swift xcode swift3 xcode8


【解决方案1】:

根据您问题中的日志,我在您的项目中看到了cocoapods。只需将inhibit_all_warnings! 标志添加到您的podfile,此标志将隐藏使用cocoapods 安装的第三方库的编译警告。

更多关于使用inhibit_all_warnings!标志的详细描述见alloy's answer。

【讨论】:

    【解决方案2】:

    快速修复

    我看到你正在使用 cocoapods。 每次你运行pod install 时,Cocoapods 都会重写你的配置。因此,您需要在 podfile 中添加此行以忽略 所有警告 或 特定 pod 的警告:

    # example to ignore all warnings from all pods
    inhibit_all_warnings!
    
    # example to ignore warnings from a specific pod
    pod 'Alamofire', :inhibit_warnings => true
    

    注意:有时也可以看到您的警告和 pod 的警告,这样您就可以防止将来出现问题。

    【讨论】:

      猜你喜欢
      • 2010-11-29
      • 2016-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-26
      • 2012-02-09
      相关资源
      最近更新 更多