消除警告
- 使用cocoapods管理的第三方库的警告,直接在podfile文件里面加入
inhibit_all_warnings!
- 加入预编译指令:
1
2
3
4
5#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
//这里是会报警告的代码
UIAlertView *alert = [[UIAlertView alloc] initWithFrame:self.view.bounds];
#pragma clang diagnostic pop
其中:-Wdeprecated-declarations
表示这里有废除,不支持的代码(UIAlertView在2.0-9.0,9.0以上弃用,所以会有警告)
那么,如何得到类似 -Wdeprecated-declarations
的标识符呢?
如果下图的 Reveal in log
有效,那么点击即可
无效的话也别急,你可以如下图操作查看,如果没有就先编译/运行一下
然后在下图红框位置找到警告的标识符
- 如果要删除一个.m里面的所有弃用的警告,如下图操作:
- 如果要删除项目中所有弃用的警告,如下图操作:
当然,你也可以填入别的标识符~ - 有的警告编译器会教你如何消除,而你只需要点一下即可!!!
添加警告
- 直接
#warning <#message#>
在自己写的三方库提供的接口下写上适用范围
1
- (void)test NS_DEPRECATED_IOS(2_0, 4_0);
也可以加点信息提示该方法弃用了
1
2
3- (void)test __attribute((deprecated("这个接口已弃用,请使用xxx!"));
或者
- (void)test NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, "这个接口已弃用,请使用xxx!");
碰到过的警告
Unused variable 'xxx'
- 没有使用Deprecated: Push segues are deprecated in iOS 8.0 and later
- iOS8之后呢,不要再用push拖线了,统一用show,他会自己根据你是否有导航栏来判断走push还是走modalUnsupported Configuration: Scene is unreachable due to lack of entry points and does not have an identifier for runtime access via -instantiateViewControllerWithIdentifier:.
- 一般是storyboard报的警告,简而言之就是你有的页面没有和箭头所指的控制器连起来,导致最终改页面可能无法显示'sizeWithFont:constrainedToSize:lineBreakMode:' is deprecated: first deprecated in iOS 7.0 - Use -boundingRectWithSize:options:attributes:context:
- 方法废除,旧的方法sizeWithFontToSize在iOS7后就废除了取而代之是boundingRectWithSize方法Undeclared selector 'historyAction'
- 使用未声明的方法,一般出现在@selector() 括号里写了个不存在的方法或方法名写错了Code will never be executed
- 代码永远也不会执行,检查代码吧"Two-stage rotation animation is deprecated. This application should use the smoother single-stage animation."
原因:不应该将UITabBarControllier嵌入到UINavigationController中作为rootViewController,但是,我们的确想要这样做,只需要在将tabbar作为rootviewcontroller之前先设置tabBarController.selectedIndex= 0
。Expected a type
: 两个类相互包含, 在其中一个使用@classPresenting view controllers on detached view controllers is discouraged <SetViewController: 0x7fedb94f0f60>.
: 因为present出来的模态窗口,禁止再使用present 来弹出其它的子窗口 解决方法:1
2
3AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
ViewController *with=[[ViewController alloc]init];
[delegate.window.rootViewController presentViewController:with animated:YES completion:^{}];This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.
: 在主线程做的事情却放在了子线程,比如发送通知,刷新UI等xcodewarning :no rule to process file xxx
: 在build phases—>compile sources 里面将对应的文件移除即可。如果有些还不行的话,xcode里面哪儿包含了这个,删。ld: warning: directory not found for option '-L/Users/xxxx/Desktop/Mos
:1
2
3选择 Build Settings 菜单,之后找到Build Settings ,在Search Paths 中有个Deug和Release点击之后有会相对的路径删除该路径,清理一下工程即可.
Library Search Paths & Framework Search Paths,
删掉编译报warning的路径Check dependencies Warning: Multiple build commands for output file
: 在copy…查找重复资源 删除一个