去除编译警告
2017-05-18 本文已影响390人
BoomLee
前言
有些时候Xcode的警告过多,或者有些警告是多余的,可以使用#pragma clang diagnostic
语法去除。
语法
- 适用整个.m文件
#pragma GCC diagnostic ignored "-W+相关命令"
@implementation BDActionSheetInvite
- 适用指定代码
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-W+相关命令"
[weakSelf performSelector:NSSelectorFromString(selectorStr)];
#pragma GCC diagnostic pop
GCC
可以替换为clang
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-W+相关命令"
[weakSelf performSelector:NSSelectorFromString(selectorStr)];
#pragma clang diagnostic pop
几个常用的命令
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "UnavailableInDeploymentTarget"
#pragma clang diagnostic ignored "-Wunused-variable"
#pragma clang diagnostic ignored "UnresolvedMessage"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#pragma clang diagnostic ignored "-Warc-retain-cycles"
参考链接
地址很有意思……
http://fuckingclangwarnings.com
去除其它警告
1.
file:///Users/lixiang/Desktop/HCSM/FlowersAndTrees/FlowersAndTrees/Search/FlowersAndTrees-Bridging-Header.h: warning: Missing file: /Users/lixiang/Desktop/HCSM/FlowersAndTrees/FlowersAndTrees/Search/FlowersAndTrees-Bridging-Header.h is missing from working copy
可以进入文件对应目录,之后使用git rm FlowersAndTrees-Bridging-Header.h
删除。
上一篇:代码规范(Objective-C)
下一篇:UISearchBar常用属性