忽略警告

2,154 阅读1分钟
  • 查找警告名

选中警告右键Reveal in Log方括号中就是警告名,如下图:

image.png

  • 忽略某一个警告
#pragma clang diagnostic push
  #pragma clang diagnostic ignored "-Warc-retain-cycles"//-Warc-retain-cycles是警告名
  //发生警告处,一般是某一行代码
  #pragma clang diagnostic pop
  • 忽略某各类中的警告 在bulidphase 中搜索到目标类 加入编译器标记,注意将'-W'开头的警告名字改成'-Wno-',如下图:
  • 忽略某个类型的警告

在buildingSetting 中other warning flags 加入要忽略的警告,如下图:

image.png

platform :ios, '9.0'
# Uncomment this line if you're using Swift
use_frameworks!
inhibit_all_warnings!//忽略所有警告
target 'My Project' do
    pod 'Alamofire', '~> 3.0', :inhibit_warnings => true//加入不加入inhibit_all_warnings! 就用这个方式一个一个库忽略
    pod 'ObjectMapper', '~> 0.19', :inhibit_warnings => false//忽略所有经警告时排除这库
    pod 'SWRevealViewController', '~> 2.3'
    pod 'XCDYouTubeKit', '~> 2.3'
    pod 'JTSImageViewController', '~> 1.5'
end