iOS 工程的警告修复


原文地址:http://www.cocoachina.com/ios/20170601/19396.html


在项目中碰到300+的警告,强迫症只能修复了

1:#warning这个后面添加中文的话,在xcode的左边警告列表页会显示不全,所以推荐使用英文注释

iOS 工程的警告修复_第1张图片

2:(Method possibly missing a [super awakeFromNib] call)这个处理,1:手动添加2:假如这个方法里面没有代码也可以删除这个方法

iOS 工程的警告修复_第2张图片

3:(Conflicting return type in implementation of 'supportedInterfaceOrientations': 'UIInterfaceOrientationMask' (aka 'enum UIInterfaceOrientationMask') vs 'NSUInteger' (aka 'unsigned long'))这个是重写系统的方法时把枚举类型的返回值写成了NSUInteger,返回值类型改回枚举就好。

4:(“View Controller“ is unreachable because it has no entry points, and no identifier for runtime access via -[UIStoryboard instantiateViewControllerWithIdentifier:].)这个警告是在一个xib中有多个storyboard其中有Storyboard ID为空的storyboard,找到删除。

5:(Automatic Preferred Max Layout Width before iOS 8.0)这个警告是因为xib中的label控件Preferred Width属性没有设置,勾选Explicit填上0就好。

iOS 工程的警告修复_第3张图片

6:(Frame for "Statuslabel" will be different at run time.)这个在xcode左边警告列表点击这个警告,会自动跳转到对应的xib,点击图上的按钮,然后Update Frames就好

iOS 工程的警告修复_第4张图片


7:(Prototype collection view cells must have reuse identifiers)这个是因为storyboard中拖入了collectionView,自带的collectionViewCell的reuse identifier为空,填入对应的reuse identifier就行

8:(warning: Attribute Unavailable: First baseline layout attribute before iOS 8.0)点击对应的警告跳转到xib界面在左边的filter中输入first,搜索出来的约束的firstItem和secondItem的constraint把两个都改为center.Y就好了

9:在podfile文件中 增加"inhibit_all_warnings!"这样pod的工程不会显示任何警告。

10:(PerformSelector may cause a leak because its selector is unknown)

WX20170525-172827@2x.png

加入这个宏:#pragma clang diagnostic ignored "-Warc-performSelector-leaks"

11:('dismissModalViewControllerAnimated:' is deprecated: first deprecated in iOS 6.0)

WX20170525-174002@2x.png

加入这个宏:#pragma clang diagnostic ignored"-Wdeprecated"

12:(Comparison of constant 'NSStreamEventErrorOccurred' (8) with expression of type 'NSStreamStatus' (aka 'enum NSStreamStatus') is always false)

加入这个宏:#pragma clang diagnostic ignored"-Wtautological-compare"

13:(Null passed to a callee that requires a non-null argument)

WX20170525-174418@2x.png

加入这个宏:#pragma clang diagnostic ignored"-Wnonnull"

14:(Undeclared selector 'DWJQkeyboardWillShow:')

iOS 工程的警告修复_第5张图片

加入这个宏:#pragma clang diagnostic ignored"-Wundeclared-selector"

15:(Logical not is only applied to the left hand side of this comparison)

加入这个宏:#pragma clang diagnostic ignored"-Wlogical-not-parentheses"

16:(Auto property synthesis will not synthesize property 'superColor'; it will be implemented by its superclass, use @dynamic to acknowledge intention)

WX20170525-175306@2x.png

加入这个宏:#pragma clang diagnostic ignored"-Wobjc-property-synthesis"

17:('sizeWithFont:forWidth:lineBreakMode:' is deprecated: first deprecated in iOS 7.0 - Use -boundingRectWithSize:options:attributes:context:)

WX20170525-175814@2x.png

加入这个宏:#pragma clang diagnostic ignored "-Wdeprecated-declarations"

18:(Unsequenced modification and access to 't')

加入这个宏:#pragma clang diagnostic ignored "-Wunsequenced"

19:(Implicit conversion loses integer precision: 'long' to 'int')

加入这个宏:#pragma clang diagnostic ignored"-Wshorten-64-to-32"

20:(Add explicit braces to avoid dangling else)

加入这个宏:#pragma clang diagnostic ignored"-Wdangling-else"

21:(Unused function 'free_linkedlist')

iOS 工程的警告修复_第6张图片

加入这个宏:#pragma clang diagnostic ignored"-Wunused-function"

附上一个查找警告和宏关系的链接:http://fuckingclangwarnings.com


你可能感兴趣的:(iOSX,Dev,Editor/IDE)