去除编译警告

作者: BoomLee | 来源:发表于2017-05-18 11:51 被阅读390次

前言

有些时候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常用属性

相关文章

网友评论

    本文标题:去除编译警告

    本文链接:https://www.haomeiwen.com/subject/bbksxxtx.html