Xcode清除警告
2021-03-01 本文已影响0人
蝴蝶之梦天使

看见警告就烦
有时候还错过了弥补的机会
不能容许
一、 屏蔽指定警告
比如:新版本Xcode的Pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)警告,OC之前的旧代码一般都不想去修改。如果是第三方库的代码,也不想去修改。

这个时候选择屏蔽是最好的选择。
1. 右键警告,选择“Reveal in Log”

2. 查看警告的类型

图中的警告为
-Wnullability-completeness
。
3. 屏蔽指定警告类型

添加

-Wno-nullability-completeness
不显示此警告。
类似的警告就会消失了。
二、清除模拟器部署版本警告
The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99.
看到这个警告一般会在Podfile的最底部添加
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '8.0'
end
end
end
但是在新版本cocoapods中使用了新特性 install! 'cocoapods', :generate_multiple_pod_projects => true, :incremental_installation => true
来加快编译的速度。
会出现undefined method
targets' for nil:NilClass`的提示,targets找不到了。使用新的方式
post_install do |installer|
installer.pod_target_subprojects.flat_map { |p| p.targets }.each do |t|
t.build_configurations.each do |c|
c.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
end
end
end
完美的解决。
三、 清除validate project settings
因为使用了install! 'cocoapods', :generate_multiple_pod_projects => true, :incremental_installation => true
后,每一个工程的部署版本比较低,会出现

点击更新后显示

指定目标版本为,明显不是我们希望的。
这个时候只能

点击Done,此警告消失。再次编译并不会再提示了。但是当第三方库的版本升级后,次警告会再次出现。
// END 等有新的警告再继续。