1.ld: warning: directory not found for option 去掉警告的方法

工程老是提示ld: warning: directory not found for option:xxxxxx 这种提示,通常是由于添加了第三方SDK,但是后来改了个名字或者去掉了SDK,但是在 Build Settings----->Search Paths----->Library Search Paths 中仍然没有删除掉对应的路径, 所以需要到Library Search Paths和Framework Search Paths中删除掉警告的路径,就OK了

2.简单消除 cocoapods第三方库警告

就是在podfile文件里面加上一行指令 。

inhibit_all_warnings!

如果某警告实在无法消除,但是又不想让他显示,可以加入预编译指令

比如我已经知道某行会报上面警告了,我就用这个宏把这几行包住,就不会报引号中-Wunused-variable的警告了

1.方法弃用警告

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
//过期的方法
#pragma clang diagnostic pop
2.不兼容指针类型警告 #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
//不兼容指针类型
#pragma clang diagnostic pop
3.循环引用警告 #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
//循环引用
#pragma clang diagnostic pop
4.未使用变量警告 #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
//未使用的变量
#pragma clang diagnostic pop
5.内存泄漏警告 #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
//内存泄漏警告
#pragma clang diagnostic pop

这个-Wunused-variable代表的意思就是 有的东西 你实例化了但是没有使用, 可以在工程总中全局配置,在项目中Build Setting里加上这个标示符,可以连着加的

三,详细科学的消除警告

1.没有使用

Cannot find protocol definition for 'TencentSessionDelegate'

2.这种明明都能运行还说我没有定义的警告,是因为你这个协议虽然定义了,但是你这个协议可能还遵守了XX协议,然后这个XX协议没有定义导致会报这种警告,所以遇到这种警告要往“父协议”找。 举个栗子,上面这行就是腾讯授权的库里面报的警告,

1
@protocol TencentSessionDelegate

此协议遵守了TencentApiInterfaceDelegate协议,在TencentOAuth.h类中#import "TencentApiInterface.h" 警告可破

Null passed to a callee that requires a non-null argument

3.这个警告比较新,是xcode6.3开始 为了让OC也能有swift的?和!的功能,你在声明一个属性的时候加上 __nullable(?可以为空)与__nonnull(!不能为空) 如果放在@property里面的话不用写下划线

1
2
@property (nonatomic, copy, nonnull) NSString * tickets;
@property (nonatomic, copy) NSString * __nonnull tickets;

或者用宏NS_ASSUME_NONNULL_BEGIN和NS_ASSUME_NONNULL_END 包住多个属性全部具备nonnull,然后仅对需要nullable的改下就行,有点类似于f-no-objc-arc那种先整体给个路线在单独改个别文件的思想。 此警告就是某属性说好的不能为空,你又在某地方写了XX = nil 所以冲突了。

Auto property synthesis will not synthesize property 'privateCacheDirectory'; it will be implemented by its superclass, use @dynamic to acknowledge intention

4.他说你的父类实现了setget方法,但是如果你什么都不写,就会系统自动生成出最一般的setget方法,请用@dynamic 来承认父类实现的这个getset方法。

Unsupported Configuration: Scene is unreachable due to lack of entry points and does not have an identifier for runtime access via -instantiateViewControllerWithIdentifier:.

5.一般是storyboard报的警告,简而言之就是你有的页面没有和箭头所指的控制器连起来,导致最终改页面可能无法显示。

Deprecated: Push segues are deprecated in iOS 8.0 and later

6.iOS8之后呢,不要再用push拖线了,统一用show,他会自己根据你是否有导航栏来判断走push还是走modal

Unsupported Configuration: Plain Style unsupported in a Navigation Item

7.导航栏的item 不支持用plain ,那就用Bordered呗。

The launch image set "LaunchImage" has 2 unassigned images.

The app icon set "AppIcon" has 2 unassigned images.

8.几张图标还是启动图找不到自己的位置,可能是一次导入了全部尺寸图片,但是右边的设置只勾了iOS8的 那iOS7尺寸的图标就会报此警告。删掉,或者对照右边匹配。

'sizeWithFont:constrainedToSize:lineBreakMode:' is deprecated: first deprecated in iOS 7.0 - Use -boundingRectWithSize:options:attributes:context:

9.方法废除,旧的方法sizeWithFontToSize在iOS7后就废除了取而代之是boundingRectWithSize方法

Undeclared selector 'historyAction'

10.使用未声明的方法,一般出现在@selector() 括号里写了个不存在的方法或方法名写错了。

PerformSelector may cause a leak because its selector is unknown

11.这个和上面类似就是直接把上面那个@SEL拿来用会报这个警告

'strongify' macro redefined

12.这个宏声明重复,删一个吧

'UITextAttributeFont' is deprecated: first deprecated in iOS 7.0 - Use NSFontAttributeName

'UITextAttributeTextColor' is deprecated: first deprecated in iOS 7.0 - Use NSForegroundColorAttributeName

'UITextAttributeTextShadowColor' is deprecated: first deprecated in iOS 7.0 - Use NSShadowAttributeName with an NSShadow instance as the value

13.方法废除,一般一起出现

Code will never be executed

14.他说这代码永远也轮不到他执行,估计是有几行代码写在了return之后

Assigning to 'id' from incompatible type 'SXTabViewController *const __strong'

15.一般出现在xxx.delegate = self ,应该在上面遵守协议

Format specifies type 'unsigned long' but the argument has type 'unsigned int'

16.这个警告一般会出现在NSStringWithFormat里面 前面%d %lu 什么的和后面填进去的参数不匹配就报了警告

Values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead

17.类似于上面,也是format里面前后写的不匹配

Method 'dealWithURL:andTitle:andKeyword:' in protocol 'SXPostAdDelegate' not implemented

18.经典警告,遵守了协议,但是没有实现协议方法。 也可能你实现了只是又加了个参数或是你写的方法和协议方法名字有点轻微不同

Using integer absolute value function 'abs' when argument is of floating point type

19.这个可以自动修正,就是说abs适用于整数绝对值,要是float取绝对值要用fabsf

Attribute Unavailable: Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0

20.有的方法你用的太落后了,也有的方法你用的太超前了。 说这个最大宽度在iOS8之前的系统是要坑的

Too many personality routines for compact unwind to encode

21.你可以在otherlink 中加入 -Wl,-no_compact_unwind 去掉该警告,根据苹果的解释,这个是由于某些地方 c/c++/oc/oc++混用会造成编译警告。一般没有什么伤害。

Property 'ssid' requires method 'ssid' to be defined - use @synthesize, @dynamic or provide a method implementation in this class implementation

22.说这个ssid必须要定义个这个属性的getter方法,如果警告是setSsid就是setter方法, 用@synthesize和@dynamic 都行,一个是让编译器生成getter和setter,一个是自己生成,如果你有模型分发或kvc之类的,选@dynamic就行

Unknown escape sequence '\)'

23.未知的转义序列。 一般有个斜杠再加个东西他都会以为是转义字符,一看\)不认识就报警告了,一般正则表达式容易报这种警告

Property 'LoginPort' not found on object of type 'LoginLvsTestTask *'; did you mean to access property loginPort?

24.这种可以点击自动修复,是典型的大小写写错了,他提醒了一下。

Variable 'type' is used uninitialized whenever switch default is taken

25.这是出现在switch语句中的警告, 一般可能是switch外面定义了个type但是并没有初始化(初始化操作都写在switch的各个分支里),然后在最后return type。 但是switch的有个分支没有对type初始化,他说如果你来到这个分支的话,那还没初始化就要被return。

四 添加警告

1.首先最常用的就是 普通警告

#warning TODO

2.如果是自己写的文件或第三方库,有了新的接口,然后提示旧的接口废除的话需要在方法后加上宏

- (void)addTapAction:(SEL)tapAction target:(id)target NS_DEPRECATED_IOS(2_0, 4_0);

3.如果需要在此方法后加上带信息的警告则需要这么写

- (void)addTapAction:(SEL)tapAction target:(id)target __attribute((deprecated("这个接口会爆内存 不建议使用")));

显示的效果像这样:

参考:http://www.cocoachina.com/ios/20150914/13287.html

iOS 警告收集快速消除的更多相关文章

  1. IOS 警告 收集

    Semantic Warnings Warning Message -WCFString-literal input conversion stopped due to an input byte t ...

  2. iOS警告收录及科学快速的消除方法

    来自: http://www.cnblogs.com/dsxniubility/p/4757760.html iOS警告收录及科学快速的消除方法     前言:现在你维护的项目有多少警告?看着几百条警 ...

  3. iOS 警告收录及科学快速的消除方法

    http://www.cocoachina.com/ios/20150914/13287.html 作者:董铂然 授权本站转载. 前言:现在你维护的项目有多少警告?看着几百条警告觉得心里烦么?你真的觉 ...

  4. 漫谈iOS Crash收集框架

    漫谈iOS Crash收集框架   Crash日志收集 为了能够第一时间发现程序问题,应用程序需要实现自己的崩溃日志收集服务,成熟的开源项目很多,如 KSCrash,plcrashreporter,C ...

  5. IOS试题收集1

    IOS试题收集1 1.Objective C中有多继承吗?没有的话用什么代替? Protocol 2.Objective C中有私有方法吗?私有变量呢? OC类里面只有静态方法和实例方法这两种,@pr ...

  6. 李洪强iOS开发之iOS社区收集

    李洪强iOS开发之iOS社区收集 项目 简述 github 全球最大的代码仓库,无论是iOS开发还是Android开发没有人不知道这个网站,它也是一个社区,你可以去follow(关注)某些人或公司. ...

  7. ios怎样实现快速将显卡中数据读出压缩成视频在cocos2dx扩展开发中

    如果解决ios怎样实现快速将显卡中数据读出压缩成视频在cocos2dx扩展开发中 手机平台性能是个关键问题. 压缩视频分成3个步骤: 读取显卡数据, 使用编码器压缩,保存文件. 使用libav 压缩的 ...

  8. 李洪强iOS开发之iOS工具收集

    李洪强iOS开发之iOS工具收集 项目 简述 日期 我是怎么慢慢变懒的 : Jenkins + 蒲公英 使用Jenkins + 蒲公英使得项目打包给测试人员自动化,大大节省了劳动力 2015.04.1 ...

  9. 李洪强iOS开发之iOS学习方法收集

    李洪强iOS开发之iOS学习方法收集 在这里收集一些iOS学习方法,会不断更新 项目 简述 日期 一年多iOS开发总结 作者总结了自己一年多的iOS学习经验,对于iOS初学者来说很多地方是可以借鉴的 ...

随机推荐

  1. [SinGuLaRiTy] NOIP模拟赛(TSY)-Day 2

    [SinGuLaRiTy-2033] Copyright (c) SinGuLaRiTy 2017. All Rights Reserved.                              ...

  2. Kibana error " Fielddata is disabled on text fields by default. Set fielddata=true on [publisher] ..."

    Reason of this error:Fielddata can consume a lot of heap space, especially when loading high cardina ...

  3. Python 之 装饰器

    装饰器 中的“器”代指函数 所以装饰器本质是函数,用来装饰其它函数.例如:为其它函数添加其他功能 实现装饰器需要的知识:  高阶函数+嵌套函数 == 装饰器 1.函数就是“变量” 函数就是“变量”说的 ...

  4. oracle ,mysql,postgres jdbc配置文件

    #db mysql #jdbc.driver=com.mysql.jdbc.Driver #jdbc.url=jdbc:mysql://localhost:3306/mysql?&useUni ...

  5. 解决三星官方移植的内核默认是没有打开支持V4L USB devices

         在linux比较新的kernel,都标配了各类摄像头的驱动支持,不用我们自己移植驱动,只需通过make menuconfig配置内核支持我们所需的摄像头类型即可.以下是在三星官方内核中配置V ...

  6. Java内存区域与内存溢出异常---对象的创建

    对象的创建   在语言层面,创建一个对象通常仅仅是一个new关键字而已.在虚拟机层面,虚拟机遇到一个new指令时,首先回去检查这个指令的参数是能在常量池中定位到一个类的符号引用,并检查这个符号引用代表 ...

  7. 牛客寒假算法基础集训营5 J 炫酷数学

    链接:https://ac.nowcoder.com/acm/contest/331/J来源:牛客网 小希最近想知道一个东西,就是A+B=A|B(其中|为按位或)的二元组有多少个. 当然,直接做这个式 ...

  8. springboot整合redis存放session

    y进入maven依赖: <!--spring boot 与redis应用基本环境配置 --> <dependency> <groupId>org.springfra ...

  9. Django 12 中间件、上下文处理器和admin后台

    Django 12 中间件.上下文处理器和admin后台 一.中间件 #Django中间件 (Middleware) # 一个轻量级.底层的“插件”系统,可以介入Django的请求和响应处理过程,修改 ...

  10. svg 日常操作

    创建svg 文件 <svg> </svg> 详解viewBox  SVG Viewport.View Box和preserveAspectRatio 形状  标签内的值可以是百 ...