1.CocoaPods警告消除 - inhibit_warnings => true
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'iOS進(jìn)階' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for iOS進(jìn)階
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查看
中括號(hào)中的"-Wunused-variable"即為該警告名稱
3.拓展
當(dāng)你需要在一段代碼消除多種警告時(shí)蒜焊,只需要添加多個(gè)警告類型
#pragma clang diagnostic ignored "<#警告名稱-Reveal in Log#>"
實(shí)際情況如下
#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#>"
影響范圍包括該行下面所有內(nèi)容