Xcode消除编译器警告
来源:互联网 发布:百胜软件工资待遇 编辑:程序博客网 时间:2024/04/28 22:47
自己项目的警告
比如我们定义一个designated initializer,参数都是nonnull
- (instancetype)initWithGivenName:(NSString *)givenName familyName:(NSString *)familyName NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithGivenName:(NSString *)givenName familyName:(NSString *)familyName{ NSAssert(givenName && familyName, @"givenName and familyName must not be nil"); if (self = [super init]) { self.givenName = givenName; self.familyName = familyName; } return self;}
当实现父类的designated initializer时,调用上面这个方法并且传入参数为nil。显然,编译器对此产生警告
- (instancetype)init{ return [self initWithGivenName:nil familyName:nil];}
- 找到警告类型
右击警告,选择在日志中显示
-W
+警告类型 : 意味着打开某种类型的警告,-Wnonnull
打开nonnull类型的警告-Wno-
+警告类型 : 意味着关闭某种类型的警告,-Wno-nonnull
关闭nonnull类型的警告
- 忽略某些行警告,被宏包裹的行忽略指定警告
#pragma clang diagnostic push#pragma clang diagnostic ignored "-Wnonnull"- (instancetype)init{ return [self initWithGivenName:nil familyName:nil];}#pragma clang diagnostic pop
值得注意的是 : 这里是-Wnonnull
- 禁用某个文件警告
- 禁用某个target警告
第三方库的警告
当我们使用CocoaPods管理库依赖时,可以通过Podfile语法禁止第三方库的警告
CocoaPods管理AFNetworking和SDWebImage
# Uncomment the next line to define a global platform for your projectplatform :ios, '9.0'target 'CocoaPodsDemoWithOC' do # Uncomment the next line if you're using Swift or would like to use dynamic frameworks # use_frameworks! # Pods for CocoaPodsDemoWithOC pod 'AFNetworking', '2.5.0' pod 'SDWebImage', '3.7.5'end
- 禁止所有来自CocoaPods的警告
inhibit_all_warnings!
# Uncomment the next line to define a global platform for your projectplatform :ios, '9.0'inhibit_all_warnings!target 'CocoaPodsDemoWithOC' do # Uncomment the next line if you're using Swift or would like to use dynamic frameworks # use_frameworks! # Pods for CocoaPodsDemoWithOC pod 'AFNetworking', '2.5.0' pod 'SDWebImage', '3.7.5'end
- 禁止指定Pod的警告
这里禁止AFNetworking的警告
# Uncomment the next line to define a global platform for your projectplatform :ios, '9.0'target 'CocoaPodsDemoWithOC' do # Uncomment the next line if you're using Swift or would like to use dynamic frameworks # use_frameworks! # Pods for CocoaPodsDemoWithOC pod 'AFNetworking', '2.5.0', :inhibit_warnings => true pod 'SDWebImage', '3.7.5'end
- 禁止除了指定Pod之外的警告
这里禁止SDWebImage的警告
# Uncomment the next line to define a global platform for your projectplatform :ios, '9.0'inhibit_all_warnings!target 'CocoaPodsDemoWithOC' do # Uncomment the next line if you're using Swift or would like to use dynamic frameworks # use_frameworks! # Pods for CocoaPodsDemoWithOC pod 'AFNetworking', '2.5.0', :inhibit_warnings => false pod 'SDWebImage', '3.7.5'end
0 0
- Xcode消除编译器警告
- Xcode强制消除警告
- Xcode 警告消除
- Xcode消除警告
- mips-linux-gcc编译器警告消除
- XCode-开发中消除警告语句
- Xcode 报错及警告消除
- 消除Xcode iOS项目的警告
- Xcode关于警告AutomaticPreferredMaxLayoutWidth的消除方法
- 强制消除Xcode警告的方法
- Xcode关于警告AutomaticPreferredMaxLayoutWidth的消除方法
- 消除Xcode iOS项目的警告
- Xcode中针对警告(黄色叹号)的忽略消除处理
- iOS开发如何消除Xcode中的警告(黄色叹号)
- 消除警告
- 消除警告
- 会报编译器警告的Xcode 6.3新特性:Nullability Annotations
- 会报编译器警告的Xcode 6.3新特性:Nullability Annotations
- iOS 性能优化总结
- 【Ubuntu】Ubuntu16.04的初始配置
- SharePoint Framework 企业向导(一)
- 把弹出窗口中的某些值传回原来网页上
- web全栈笔记之DIV+CSS布局
- Xcode消除编译器警告
- 利用自己的数据微调caffenet
- Android 中文字符转UTF-8编码
- 第七届山东省ACM省赛 A Julyed
- TCP/IP协议
- gnu嵌入式汇编的基本格式
- 知识总结之 AsyncTask 源码解析
- es6学习手记
- 最近工作中遇到ElasticSearch一些问题总结