美文网首页iOS 的那些事儿
消除Xcode警告(OC警告)

消除Xcode警告(OC警告)

作者: Robinone | 来源:发表于2019-07-20 20:55 被阅读0次

1.CocoaPods警告消除 - inhibit_warnings => true

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'iOS进阶' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for iOS进阶
  pod 'RBScrollTextView', :inhibit_warnings => true
end

需要重新 pod install

2.Xcode常见OC警告消除

#pragma clang diagnostic push
#pragma clang diagnostic ignored "<#警告名称-Reveal in Log#>"
<#要消除警告的代码#>
#pragma clang diagnostic pop

警告名称通过右击警告,Reveal in Log查看
中括号中的"-Wunused-variable"即为该警告名称


Reveal in Log in Xcode
警告名称

3.拓展

当你需要在一段代码消除多种警告时,只需要添加多个警告类型

#pragma clang diagnostic ignored "<#警告名称-Reveal in Log#>"

实际情况如下


#import "RBPerson.h"
#import "RBNil.h"
@implementation RBPerson


- (void)test {
    RBEmpty *e = [RBEmpty emptyWithName:@""];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wunused-variable"
    RBEmpty *e1 = [RBEmpty new];
    e.name = @"";
    RBNil *n = [[RBNil alloc] init];
#pragma clang diagnostic pop
}

@end

只写一行
#pragma clang diagnostic ignored "<#警告名称-Reveal in Log#>"
影响范围包括该行下面所有内容

相关文章

  • 消除Xcode警告(OC警告)

    1.CocoaPods警告消除 - inhibit_warnings => true 需要重新 pod insta...

  • Xcode 消除警告

    1.注释警告 2.查看警告类型 得到警告类型 如: -Wunused-variable 再w 后面加 no- 进行...

  • xcode消除警告

    本人有一点小小的强迫症,那就是,项目中,不想看到警告.没办法的是,技术不行,只能一点一点的积累了.这个会长期更新....

  • Xcode消除警告

    1、warning: no rule to process file '*.h' of type sourceco...

  • Xcode 消除警告

    在警告处插入一下代码 获取到警告的类型 先编译,编译完成后如下图oc_warn_cancle_01.png 筛选完...

  • Xcode关于警告AutomaticPreferredMaxLa

    Xcode关于警告AutomaticPreferredMaxLayoutWidth的消除方法 在iOS开发中,如果...

  • iOS编译警告

    iOS编译警告-消除方法参数检查相关的警告 iOS编译警告-消除注释中的警告

  • Xcode警告消除宏

    在iOS开发过程中, 我们可能会碰到一些系统方法弃用, weak、循环引用、不能执行之类的警告。 有代码洁癖的孩子...

  • 强制消除Xcode警告

    在iOS开发过程中, 我们可能会碰到一些系统方法弃用, weak、循环引用、不能执行之类的警告。 有代码洁癖的孩子...

  • 消除Xcode编译警告

    最近项目做完了,开始进行优化,第一件事就是消除编译警告。编译警告虽然不会导致项目崩溃,但是看着烦。一边消除一边记录...

网友评论

    本文标题:消除Xcode警告(OC警告)

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