iOS中去除 Warning警告

本文介绍如何使用预编译指令消除Clang编译器中因使用过期方法产生的警告信息。通过具体步骤演示了如何找到并忽略特定的警告标识,以及如何从编译源文件列表中移除不需要处理的文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

过期方法的 warning 消除

#pragma clang diagnostic push
#pragma clang diagnostic ignored "警告标识的描述"  // 例如 -Wdeprecated-declarations
//    过期的方法      //
#pragma clang diagnostic pop

//  for example 

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
        return [self.text sizeWithFont:self.font constrainedToSize:CGSizeMake(CGFLOAT_MAX, height) lineBreakMode:self.lineBreakMode];
#pragma clang diagnostic pop

//警告标识的描述 的查找方法 
step 1) find "show the issue navigator"

step 2) find the issue 

step 3) reveal in log 

step 4) read message such as 
UILabel+Extension.m:48:27: warning: 'sizeWithFont:constrainedToSize:lineBreakMode:' is deprecated: first deprecated in iOS 7.0 - Use -boundingRectWithSize:options:attributes:context:
 
 
 [-Wdeprecated-declarations] // 描述标识 

复制代码

architecture x86_64

warning: no rule to process file 'README.md' of type net.daringfireball.markdown for architecture x86_64. 引用地址

we can resolve that things with simply following step:-

Step 1) Select Project Navigator
Step 2) Select your project
Step 3) Select your targetStep 
4) Select Build PhasesStep 
5) Move files which we don't want the compiler to process from Compile Sources to Copy Bundle Resources

复制代码

解决方式2

引用位置

Select the project target
Select the Build Phases
Expand the Compile Source
Remove the Header file (Reachability.h)
note : for removing the Reachability.h file from Compile Source, first select the file and then press the - button

If you need the header, then make sure that it is added to the "Headers" list below "Compile Sources".

复制代码
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值