iOS优化-Xcode编译警告信息

1.对整个文件使用

你的工程 -> 你的target -> Build Phases -> Compile Sources -> 搜索要忽略警告的文件名,在 Compiler Flags 列 双击,键入忽略警告的设置。多个设置项使用空格隔开。
常用的几种警告:

// 忽略未使用变量的警告
-Wno-unused-variable
// 忽略已过期的类或类成员的警告
-Wno-deprecated-declarations
// 忽略一个文件所有的编译警告
-w
2.对某段代码使用

在要使用的代码处,加入如下代码:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// 作用范围内的代码 
#pragma clang diagnostic pop
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
// 作用范围内的代码 
#pragma clang diagnostic pop

-Wdeprecated-declarations可以消除使用了不建议的Api的警告,-Wdeprecated-implementations处理实现了废弃的方法

3.对整个工程使用(不推荐)

在 Build Settings 里,搜索
Inhibit All Warnings ,设置为YES

4.ambiguous expansion of macro的warning

用pod install后,pod工程里出现ambiguous expansion of macro的warning,对于有代码洁癖的人,这个让人难以忍受
去掉warning的办法
1.选择Project–>Build Setting
2.搜Enable Modules,找到后设置为NO,搞定!

5.warning:‘ld: warning: directory not found for option’

另外记录一下去掉xcode编译warning:‘ld: warning: directory not found for option’
1.选择工程Target
2.选择 Build Settings
3.搜Library Search Paths 和 Framework Search Paths,删除编译warning的路径

警告消除相关文章

iOS忽略警告方法记录

IOS忽略警告

iOS中忽略警告

iOS项目忽略警告方法

IOS中忽略警告的三种方法

iOS 警告消除(记录贴)

iOS工程中如何去掉第三方的警告

iOS工程中如何去掉第三方的警告

Cocoapods 应用——警告处理

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。