本文翻译自:Ignore Xcode warnings when using Cocoapods
I use quite a lot third party libraries which have many warnings in it, after the latest Xcode updates. 在最新的Xcode更新之后,我使用了很多第三方库,其中有许多警告。 (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. (例如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安装”之后,更改都会被丢弃。
#1楼
参考:https://stackoom.com/question/tQ3W/使用Cocoapods时忽略Xcode警告
#2楼
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
然后执行: pod install
#3楼
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构建设置中搜索“inhibit_all_warnings”,将值设置为“YES”,它将隐藏所有Pod文件警告。
If you do it to your work space it will hide all your project also. 如果你对你的工作空间这样做,它也会隐藏你的所有项目。
#4楼
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). 虽然这个其他答案将在构建阶段删除警告,但它似乎并未完全修复Analyze
阶段(这导致我们的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 onBuild Settings
选择实际的Pod-
Target并单击Build Settings
- Filter with the phrase
compiler flags
使用短语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! 添加一个新的Other C Flags
,其值为-w -Xanalyzer -analyzer-disable-checker -Xanalyzer core
(或者您需要禁用的任何分析器) - 这个答案提供了要尝试的完整标志列表 - 请点赞它!The version of
clang
in Xcode 6.3.1, though, doesn't seem to includeinsecureAPI
so you can remove it from that list. 但是,Xcode 6.3.1中的clang
版本似乎不包含insecureAPI
因此您可以从该列表中删除它。 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
“当前”完整列表是-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
Note that setting this on the Pods
Project or Pods
Target will not work . 请注意,在Pods
项目或Pods
目标上设置此项将不起作用 。 I'm not sure why, but you have to set it for each actual Pod-
target. 我不确定为什么,但你必须为每个实际的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 core
等)。
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. 它们是在Pods
项目上进行的。
[1] [1]
- Filter with the phrase
analyzer
使用短语analyzer
过滤 - Make sure
Analyze During 'Build'
is set toNO
. 确保Analyze During 'Build'
设置为“NO
。 - Change all the settings to
NO
(includingImproper Memory Management
) 将所有设置更改为NO
(包括Improper Memory Management
)
[2] [2]
- Filter with the phrase
warnings
使用短语warnings
过滤 - Change
inhibit all warnings
toYES
更改inhibit all warnings
为YES
For some reason, even disabling the
Analyze
step in the scheme doesn't seem to work.
出于某种原因,即使禁用方案中的
Analyze
步骤似乎也不起作用。
Go to the
Product > Scheme > Manage Schemes
window, click on each
Pod-*
from the list and click the
Edit
button.
转到
Product > Scheme > Manage Schemes
窗口,单击列表中的每个
Pod-*
,然后单击
Edit
按钮。
Click
Build
on the left-hand list, and then
uncheck
Analyze
on the right-hand side for the
Pod
target.
单击左侧列表中的
Build
,然后
取消选中
Pod
目标右侧的
Analyze
。
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. 我仍然感到困惑,为什么我不能完全禁用Pods被分析,虽然我希望它可能与方案的构建设置中选中的“查找隐式依赖项”有关。 If that was unchecked, though, it looks like something else would need to happen for the app to link to the pods. 但是,如果未经检查,则看起来应用程序需要发生其他内容才能链接到pod。
#5楼
Step: 1 Put the below script in your Podfile. 步骤:1将以下脚本放入Podfile中。
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'] = "YES"
end
end
end
Step 2. Do pod install
. 步骤2.执行pod install
。