2014-10-02 74 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