2014-10-02 73 views
11

我有一个与CocoaPods一起设置的Xcode工作区。当我在我的项目上运行Xcode的分析器时,它会分析我自己的源代码以及Pods目标中的所有源代码。这引发了很多我不感兴趣的警告,因为我只想看到自己的源代码的分析器警告。Xcode分析器 - 忽略CocoaPods目标

我没有选择从生成目标的“分析”豆荚,但这似乎没有任何效果。

有没有办法在运行分析仪时忽略Pods目标?

enter image description here

+1

答案在这里http://stackoverflow.com/questions/13208202/ignore-xcode-warnings-when-using-cocoapods – 2015-05-17 16:01:11

+1

@YuriSolodkin这是警告,而不是静态分析仪的警告 – CarmeloS 2015-07-21 07:08:05

回答

3

您可以添加一个安装后你podfile的结束步骤,以增加编译器标志控制的静态分析。

post_install do |installer| 
    puts 'Removing static analyzer support' 
    installer.project.targets.each do |target| 
     target.build_configurations.each do |config| 
      config.build_settings['OTHER_CFLAGS'] = "$(inherited) -Qunused-arguments -Xanalyzer -analyzer-disable-all-checks" 
     end 
    end 
end 

然后只需运行“pod update”命令重新生成项目文件。

不同部分:

  • $(继承) - 一个很好的习惯,不能避免意外删除标志
  • -Qunused论点 - LLVM不理解铛选项,这个沉默的主编译产生的警告
  • -Xanalyzer -analyzer-disable-all-checks - 这会通知静态分析器忽略关联项目中的文件。
+0

这适用于我的Cocoapods 0.35.0。 – CarmeloS 2015-07-29 06:47:39

5

下面是现有的答案更新/修改:

随着获得项目所需的CocoaPods 0.38+安装属性发生变化,这样你需要使用“pods_project”而不是“项目”,例如:

post_install do |installer| 
    puts 'Removing static analyzer support' 
    installer.pods_project.targets.each do |target| 
     target.build_configurations.each do |config| 
      config.build_settings['OTHER_CFLAGS'] = "$(inherited) -Qunused-arguments -Xanalyzer -analyzer-disable-all-checks" 
     end 
    end 
end 

请参阅有关变更的详细信息如下的CocoaPods博客公告:http://blog.cocoapods.org/CocoaPods-0.38/#breaking-change-to-the-hooks-api

而且,这里的显示错误你将一个(封闭的)问题接收,如果你尝试旧的方式与新代码:https://github.com/CocoaPods/CocoaPods/issues/3918