使用 Cocoapods 时忽略 Xcode 警告
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13208202/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ignore Xcode warnings when using Cocoapods
提问by KrauseFx
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 install”之后,更改都会被丢弃。
回答by alloy
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
回答by Teja Swaroop
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.
如果你在你的工作空间里这样做,它也会隐藏你的所有项目。
回答by Jedidja
Although this other answerwill 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 - Choose the actual
Pod-
Target and click onBuild Settings
- 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 answerprovides the full list of flags to try -- please upvote it!The version of
clang
in Xcode 6.3.1, though, doesn't seem to includeinsecureAPI
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
Pods
从项目导航器中单击项目- 选择实际
Pod-
目标并单击Build Settings
- 用短语过滤
compiler flags
添加一个新
Other C Flags
的值-w -Xanalyzer -analyzer-disable-checker -Xanalyzer core
(或您需要禁用的任何分析器)-此答案提供了要尝试的完整标志列表-请点赞!clang
但是,Xcode 6.3.1 中的版本似乎不包括在内,insecureAPI
因此您可以将其从该列表中删除。“当前”完整列表是-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. I'm not sure why, but you have to set it for each actual Pod-
target.
请注意,在Pods
Project 或Pods
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
- Make sure
Analyze During 'Build'
is set toNO
. - Change all the settings to
NO
(includingImproper Memory Management
)
- 用短语过滤
analyzer
- 确保
Analyze During 'Build'
设置为NO
。 - 将所有设置更改为
NO
(包括Improper Memory Management
)
[2]
[2]
- Filter with the phrase
warnings
- Change
inhibit all warnings
toYES
- 用短语过滤
warnings
- 更改
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. Click Build
on the left-hand list, and then uncheckAnalyze
on the right-hand side for the Pod
target.
转到Product > Scheme > Manage Schemes
窗口,单击Pod-*
列表中的每一个,然后单击Edit
按钮。单击Build
左侧列表,然后取消选中Analyze
右侧的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 进行分析感到困惑,尽管我预计这可能与在方案的构建设置中检查的“查找隐式依赖项”有关。但是,如果未选中该选项,则应用程序链接到 Pod 似乎还需要执行其他操作。
回答by Toseef Khilji
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
。