在使用Cocoapods时忽略Xcode警告

时间:2023-01-27 10:48:42

I use quite a lot third party libraries which have many warnings in it, after the latest Xcode updates. (for example the Facebook SDK pod) Now all these warnings are shown in my Xcode on the place I want to see my own warnings or errors.

在最新的Xcode更新之后,我使用了很多第三方库,其中有很多警告。(例如Facebook SDK pod)现在所有这些警告都显示在我的Xcode中,我希望看到自己的警告或错误。

Is there any way to ignore these errors? Fixing them won't help, since after every "pod install" the changes are discarded.

有什么方法可以忽略这些错误吗?修复它们不会有任何帮助,因为每次“pod安装”之后,更改都会被丢弃。

3 个解决方案

#1


722  

Add to your Podfile:

添加到您的Podfile:

platform :ios

# ignore all warnings from all pods
inhibit_all_warnings!

# ignore warnings from a specific pod
pod 'FBSDKCoreKit', :inhibit_warnings => true

Then execute: pod install

然后执行:舱安装

#2


19  

You can search for "inhibit_all_warnings" in xcode build settings of the PodBundle in your project-work space the set the value to "YES" it will hide all you Pod file warnings.

您可以在项目工作空间的PodBundle的xcode构建设置中搜索“抑制性_all_warning”,将值设置为“YES”,它将隐藏所有Pod文件警告。

If you do it to your work space it will hide all your project also.

如果你对你的工作空间这样做,它也会隐藏你所有的项目。

#3


2  

Although this other answer will remove warnings during the build phase, it doesn't appear to completely fix the Analyze phase (which caused our CI build to still have issues).

尽管另一个答案将在构建阶段删除警告,但它似乎并没有完全修复分析阶段(这导致我们的CI构建仍然存在问题)。

What worked for me (in addition to the accepted answer) was:

对我起作用的(除了公认的答案)是:

  • Click on the Pods project from the Project Navigator
  • 单击project Navigator中的Pods项目
  • Choose the actual Pod- Target and click on Build Settings
  • 选择实际的Pod- Target并单击Build设置
  • Filter with the phrase compiler flags
  • 使用短语编译器标记进行筛选。
  • Add a new Other C Flags with the value -w -Xanalyzer -analyzer-disable-checker -Xanalyzer core (or whichever analyzers you need disabled) - this answer provides the full list of flags to try -- please upvote it!

    添加一个新的带有值-w - xanalyzer -analyzer-disable-checker - xanalyzer核心(或任何您需要禁用的分析器)的C标志-这个答案提供了要尝试的标志的完整列表——请向上投!

    The version of clang in Xcode 6.3.1, though, doesn't seem to include insecureAPI so you can remove it from that list. The "current" full list is -w -Xanalyzer -analyzer-disable-checker -Xanalyzer alpha -Xanalyzer -analyzer-disable-checker -Xanalyzer core -Xanalyzer -analyzer-disable-checker -Xanalyzer cplusplus -Xanalyzer -analyzer-disable-checker -Xanalyzer deadcode -Xanalyzer -analyzer-disable-checker -Xanalyzer debug -Xanalyzer -analyzer-disable-checker -Xanalyzer llvm -Xanalyzer -analyzer-disable-checker -Xanalyzer osx -Xanalyzer -analyzer-disable-checker -Xanalyzer security -Xanalyzer -analyzer-disable-checker -Xanalyzer unix

    不过,Xcode 6.3.1中的clang版本似乎不包含insecureAPI,因此您可以从该列表中删除它。“当前”完整列表是-w -Xanalyzer -分析器-去功能化检查-Xanalyzer -分析器-分析器-分析器-去功能化检查-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-analyzer-disable-checker -Xanalyzer unix

Note that setting this on the Pods Project or Pods Target will not work. I'm not sure why, but you have to set it for each actual Pod- target.

注意,在Pods项目或Pods目标上设置这个参数将不起作用。我不知道为什么,但是你必须为每个实际的Pod目标设置它。

You can also set the compiler flags (-w -Xanalyzer -analyzer-disable-checker -Xanalyzer core etc.) on a per-file basis.

您还可以在每个文件的基础上设置编译器标记(-w -Xanalyzer -analyzer-disable-checker -Xanalyzer核等等)。

I also tried a couple other methods (which may or may not be required in addition to the above). They were performed on the Pods Project itself.

我还尝试了一些其他的方法(除了上面的方法外,这些方法可能是必需的,也可能不是必需的)。它们是在豆荚项目中进行的。


[1]

[1]

  • Filter with the phrase analyzer
  • 使用短语分析器进行过滤
  • Make sure Analyze During 'Build' is set to NO.
  • 确保“构建”期间的分析被设置为NO。
  • Change all the settings to NO (including Improper Memory Management)
  • 将所有设置更改为NO(包括不正确的内存管理)

[2]

[2]

  • Filter with the phrase warnings
  • 用短语警告过滤。
  • Change inhibit all warnings to YES
  • 更改将所有警告禁止为YES

For some reason, even disabling the Analyze step in the scheme doesn't seem to work.

出于某种原因,甚至禁用该方案中的分析步骤似乎也不起作用。

Go to the Product > Scheme > Manage Schemes window, click on each Pod-* from the list and click the Edit button. Click Build on the left-hand list, and then uncheck Analyze on the right-hand side for the Pod target.

进入产品>方案>管理方案窗口,点击列表中的每个Pod-*,点击编辑按钮。单击左侧列表上的Build,然后在右侧取消对Pod目标的分析。

I am still confused as to why I can't completely disable the Pods from being analyzed, although I expect it might have to do with the "Find implicit dependencies" checked in the scheme's build settings. If that was unchecked, though, it looks like something else would need to happen for the app to link to the pods.

我仍然困惑于为什么我不能完全禁用这些pod,尽管我希望它可能与在scheme的构建设置中检查的“发现隐式依赖关系”有关。不过,如果不加以控制,它看起来就像应用程序连接到pod的其他东西。

#1


722  

Add to your Podfile:

添加到您的Podfile:

platform :ios

# ignore all warnings from all pods
inhibit_all_warnings!

# ignore warnings from a specific pod
pod 'FBSDKCoreKit', :inhibit_warnings => true

Then execute: pod install

然后执行:舱安装

#2


19  

You can search for "inhibit_all_warnings" in xcode build settings of the PodBundle in your project-work space the set the value to "YES" it will hide all you Pod file warnings.

您可以在项目工作空间的PodBundle的xcode构建设置中搜索“抑制性_all_warning”,将值设置为“YES”,它将隐藏所有Pod文件警告。

If you do it to your work space it will hide all your project also.

如果你对你的工作空间这样做,它也会隐藏你所有的项目。

#3


2  

Although this other answer will remove warnings during the build phase, it doesn't appear to completely fix the Analyze phase (which caused our CI build to still have issues).

尽管另一个答案将在构建阶段删除警告,但它似乎并没有完全修复分析阶段(这导致我们的CI构建仍然存在问题)。

What worked for me (in addition to the accepted answer) was:

对我起作用的(除了公认的答案)是:

  • Click on the Pods project from the Project Navigator
  • 单击project Navigator中的Pods项目
  • Choose the actual Pod- Target and click on Build Settings
  • 选择实际的Pod- Target并单击Build设置
  • Filter with the phrase compiler flags
  • 使用短语编译器标记进行筛选。
  • Add a new Other C Flags with the value -w -Xanalyzer -analyzer-disable-checker -Xanalyzer core (or whichever analyzers you need disabled) - this answer provides the full list of flags to try -- please upvote it!

    添加一个新的带有值-w - xanalyzer -analyzer-disable-checker - xanalyzer核心(或任何您需要禁用的分析器)的C标志-这个答案提供了要尝试的标志的完整列表——请向上投!

    The version of clang in Xcode 6.3.1, though, doesn't seem to include insecureAPI so you can remove it from that list. The "current" full list is -w -Xanalyzer -analyzer-disable-checker -Xanalyzer alpha -Xanalyzer -analyzer-disable-checker -Xanalyzer core -Xanalyzer -analyzer-disable-checker -Xanalyzer cplusplus -Xanalyzer -analyzer-disable-checker -Xanalyzer deadcode -Xanalyzer -analyzer-disable-checker -Xanalyzer debug -Xanalyzer -analyzer-disable-checker -Xanalyzer llvm -Xanalyzer -analyzer-disable-checker -Xanalyzer osx -Xanalyzer -analyzer-disable-checker -Xanalyzer security -Xanalyzer -analyzer-disable-checker -Xanalyzer unix

    不过,Xcode 6.3.1中的clang版本似乎不包含insecureAPI,因此您可以从该列表中删除它。“当前”完整列表是-w -Xanalyzer -分析器-去功能化检查-Xanalyzer -分析器-分析器-分析器-去功能化检查-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-分析器-analyzer-disable-checker -Xanalyzer unix

Note that setting this on the Pods Project or Pods Target will not work. I'm not sure why, but you have to set it for each actual Pod- target.

注意,在Pods项目或Pods目标上设置这个参数将不起作用。我不知道为什么,但是你必须为每个实际的Pod目标设置它。

You can also set the compiler flags (-w -Xanalyzer -analyzer-disable-checker -Xanalyzer core etc.) on a per-file basis.

您还可以在每个文件的基础上设置编译器标记(-w -Xanalyzer -analyzer-disable-checker -Xanalyzer核等等)。

I also tried a couple other methods (which may or may not be required in addition to the above). They were performed on the Pods Project itself.

我还尝试了一些其他的方法(除了上面的方法外,这些方法可能是必需的,也可能不是必需的)。它们是在豆荚项目中进行的。


[1]

[1]

  • Filter with the phrase analyzer
  • 使用短语分析器进行过滤
  • Make sure Analyze During 'Build' is set to NO.
  • 确保“构建”期间的分析被设置为NO。
  • Change all the settings to NO (including Improper Memory Management)
  • 将所有设置更改为NO(包括不正确的内存管理)

[2]

[2]

  • Filter with the phrase warnings
  • 用短语警告过滤。
  • Change inhibit all warnings to YES
  • 更改将所有警告禁止为YES

For some reason, even disabling the Analyze step in the scheme doesn't seem to work.

出于某种原因,甚至禁用该方案中的分析步骤似乎也不起作用。

Go to the Product > Scheme > Manage Schemes window, click on each Pod-* from the list and click the Edit button. Click Build on the left-hand list, and then uncheck Analyze on the right-hand side for the Pod target.

进入产品>方案>管理方案窗口,点击列表中的每个Pod-*,点击编辑按钮。单击左侧列表上的Build,然后在右侧取消对Pod目标的分析。

I am still confused as to why I can't completely disable the Pods from being analyzed, although I expect it might have to do with the "Find implicit dependencies" checked in the scheme's build settings. If that was unchecked, though, it looks like something else would need to happen for the app to link to the pods.

我仍然困惑于为什么我不能完全禁用这些pod,尽管我希望它可能与在scheme的构建设置中检查的“发现隐式依赖关系”有关。不过,如果不加以控制,它看起来就像应用程序连接到pod的其他东西。