警告提示收集

 

其他人的:

https://www.jianshu.com/p/a1aa0df5aa3c

 

Enum values with underlying type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead

或 Values of type ‘NSInteger’ should not be used as format arguments; add an explicit cast to ‘long’ instead
FIX: Replace
'%d, animated = %d", __FUNCTION__, ' with '%ld, animated = %d", __FUNCTION__, (long)'

苹果app支持arm64以后会有一个问题:NSInteger变成64位了,和原来的int (%d)不匹配,所以会报warning,

NSInteger的定义(如下),在64位系统中NSInteger是long, 32位中是int。所以"%d"在64位上当然是不足以够位长,这里修改为"%ld"合情合理。

#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
  typedef long NSInteger;
  typedef unsigned long NSUInteger;
#else
  typedef int NSInteger;
  typedef unsigned int NSUInteger;
#endif
 

其它方式:强制转换    [NSString stringWithFormat:@"%d"(int)number];

     [NSString stringWithFormat:@“%@", @(number)];

 

Unused variable 未使用的变量

https://blog.csdn.net/nwpu053883/article/details/103351032

https://stackoverflow.com/questions/7090998/portable-unused-parameter-macro-used-on-function-signature-for-c-and-c

 

指针类型不兼容
Incompatible pointer types assigning to 'AAA *' from 'BBB *'  

 Incompatible pointer types returning 'AAA' from a function with result type 'BBB'

 

 

Duplicate key in dictionary literal 在字典字面量中重复键

Multiple declarations of method 'xxx:' found and ignored 方法'xxx:'的多个声明被发现和忽略

 

Null passed to a callee that requires a non-null argument

此警告就是某属性说好的不能为空,你又在某地方写了 nil 所以冲突了

在宏NS_ASSUME_NONNULL_BEGIN和NS_ASSUME_NONNULL_END 包住,全部具备nonnull

 出现的原因是由于Xcode10以后,系统对新建类默认加上NS_ASSUME_NONNULL_BEGINNS_ASSUME_NONNULL_END这样的一对宏,但是我们对某些对象置nil而导致的。 知道了原因先来看下介这对宏的作用:我们都知道Swift将对象分为optional(?)non-optional(!)的,但是OC却没有这一特性。为了解决Swift和OC混编时的对象问题,Xcode6.3时苹果推出了这样的一对宏。这对宏的主要作用是将在这两个宏之间的代码,所有简单指针对象都会被假定为nonnull,因此我们只需要去指定那些nullable的指针。 因为所有对象都被假定为nonnull了,而这时将某一对象或参数置nil,所以编译器会报此警告。

解决的方法也很简单,我们只要在申明对象时对需要nil的对象或参数,加上nullable关键字即可。

从这个警告可以发现,苹果一直想让OC往Swift的方向发展兼容,从Xcode6.3的提出,到Xcode10的默认添加都能看出。

 


  is deprecated: 已弃用

 'openURL:' is deprecated: first deprecated in iOS 10.0
 Replace 'openURL' with 'openURL:options:completionHandler:'

 'automaticallyAdjustsScrollViewInsets' is deprecated: first deprecated in iOS 11.0 - Use UIScrollView's contentInsetAdjustmentBehavior instead

 已弃用的方法与替换方法

 

Undeclared selector 'aaa'

未申报的选择器 aaa

Method definition for 'aaa:' not found

未找到'aaa '的方法定义

 

Empty paragraph passed to '@param' command

其实原因就是注释不合苹果的要求,所以,出现了新的警告,要么修改这些警告为要求的格式,要么全局隐藏这些警告。但是因为引入了第三方友盟,所以,不大可能去直接修改这些文件。要么更新友盟SDK到最新版本(友盟官方未必已经解决),要么就全局隐藏。

如何全局消除这些警告呢?

如下:在Other Warning Flags 里面添加-Wno-documentation

 

#pragma 处理警告 https://www.jianshu.com/p/3c7a4feaee16 

 

方法注释的正确写法是什么?

 

 

Parameter 'date' not found in the function declaration

Empty paragraph passed to '@param' command

 

 

 

This block declaration is not a prototype

typedef void(^transactionBlock)(); 

()里没有填写void,在xcode9中会提示一个警告

typedef void(^transactionBlock)(void);

 

但是这样,很多第三方要改,涉及的面太大了,目前可能不太适合,虽然这个是趋势.

或者,如果只是很少的地方,也可以使用彻底的暂时解决所有这种警告的方式

在工程的设置中

strict-prototypes 设置为NO,则这些警告就消失了

 

Block implicitly retains 'self'; explicitly mention 'self' to indicate this..

其中的意思是block中使用了self的实例变量 _xxx ,因此block会隐式的retain住self。Xcode认为这可能会给开发者造成困惑,或者因此而因袭循环引用,所以警告我们要显示的在block中使用self,以达到block显示retain住self的目的。

  • 方案一:

  按照Xcode提示,改成self->_xxx

  • 方案二:

   Building Settings->CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF 设置为NO

 

This old-style function definition is not preceded by a prototype

即使函数括号内没有任何参数,也要加一个void类型,来避免这种warning

 

iOS 开发去除 CocoaPods 警告(Fix Xcode Warning)

https://blog.csdn.net/hongfengkt/article/details/82626147?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-82626147-blog-81701169.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-82626147-blog-81701169.pc_relevant_paycolumn_v3&utm_relevant_index=2

因为从 Xcode8.0 开始,引入了文档注释的警告 。

 

Implicit conversion loses integer precision: 'UIInterfaceOrientation' (aka 'enum UIInterfaceOrientation') to 'int'

出现Implicit conversion loses integer precision: 'NSUInteger' (aka 'unsigned long') to 'int意思是NSUinteger隐式转换int会丢失精度,会报这个⚠️但是程序可以正常运行,要消掉这个警告需要手动转换比如:
(int)array.count

或者在build phases 对应文件添加  -Wno-shorten-64-to-32

其他参考:

https://blog.csdn.net/yohunl/article/details/41984505

https://zhuanlan.zhihu.com/p/50978296

 

stringByAddingPercentEscapesUsingEncoding 警告

这个方法从2.0支持到 9.0后不支持了,建议用
stringByAddingPercentEncodingWithAllowedCharacters 替换

例:

NSString *hStr = @"你好啊";
NSString *hString = [hStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

替换后: 

NSString *hStr =@"你好啊";
NSString *hString = [hStr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];

 

其他参考:

https://blog.csdn.net/rhddlr/article/details/88787915

 

 

Assigning to 'id<cccDelegate> _Nullable' from incompatible type 'xxxVC *' 

提示分配给"UITextFieldDelegate"是类型有误的!从不兼容类型“
xxxVC*”分配到“id<cccDelegate> _Nullable”

基本上是由两种情况造成的:


1、没有遵守协议(基本上都是这种情况造成的)


解决办法:遵守这个协议



2、strong 类型不兼容


解决办法:将 strong 改为 weak 

 

 

This file is set to build for a version older than the deployment target. Functionality may be limited.
将此文件设置为针对比部署目标更老的版本进行构建。功能可能有限。

解决方法:

选中xib 的文件 , 在 show the file inspector 选项栏中的 Interface Builder Document 下的 Builds for 选中  Project Deployment Target

参考:https://blog.csdn.net/liwenjie0912/article/details/49682457 

 

Implicit conversion from enumeration type 'enum CFNumberFormatterStyle' to different enumeration type 'NSNumberFormatterStyle' (aka 'enum NSNumberFormatterStyle')

隐式转换问题
CFNumberFormatterStyle 改用 NSNumberFormatterDecimalStyle 

其他相关: 

Implicit conversion from enumeration type 'enum CGImageAlphaInfo' to different enumeration type 'CGB... https://blog.csdn.net/weixin_34319640/article/details/93931387

Xcode:获得警告“来自枚举类型UIDeviceOrientation的隐式转换" https://www.it1352.com/1691313.html

Implicit conversion from enumeration type 'enum UIControlEvents' to different enumeration type 'UIControlState' (aka 'enum UIControlState')

 

 

 

Method override for the designated initializer of the superclass '-init' not found
未找到超类'-init'的指定初始化式的方法重写

重写init方法 或 禁用init方法
参考: https://www.jianshu.com/p/c8f6aafb0117

 

警告提示:Capturing ‘self‘ strongly in this block is likely to lead to a retain cycle

Capturing 'self' strongly in this block is likely to lead to a retain cycle

代码中写了self,然后xcode给出这样的提示。

1. __block ViewController *strongSelf = self;
2.将self修改为:strongSelf

 

3.举例说明:

 __block PracticeWriteUIView *strongSelf = self;// 上面步骤1
 [_bv4_describleDo addTargetForControlEvents:UIControlEventTouchUpInside action:^(id sender) {
       [strongSelf->_collectionViewNow scrollToItemAtIndexPath:1];// 上面步骤2(只是把之前用self改为了strongSelf)
  }];


参考文档:

https://blog.csdn.net/grl18840839630/article/details/81235089
https://blog.csdn.net/Amencome/article/details/45362813

 

无法安装此app,因为无法验证其完整性

解决方案参考:
https://www.jianshu.com/p/a3eb50c22117
https://developer.yonyou.com/forum.php?mod=viewthread&tid=170589&extra=page%3D1&page=1
https://www.mango66.com/jiadian/677394.html
https://www.i4.cn/news_detail_33000.html
https://zhidao.baidu.com/question/1710692855597906700

 

Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and optio...

服务器返回的数据不是JSON格式或者不是合法的JSON格式,要不然让服务器修改一下,要不然加下面一句代码

AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
session.responseSerializer = [AFHTTPResponseSerializer serializer];

作者:FisherJiam
链接:https://www.jianshu.com/p/64546e4f2ad9
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

 

 

[NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Perm...

最近使用Xcode 10.1运行App的时候,控制台总是频繁打印如下日志:
2019-02-27 17:43:19.239825+0800 siruoxian[28799:1433202] [NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor: <CTServiceDescriptor 0x2814f7b40, domain=1, instance=1>
经查证和[CTTelephonyNetworkInfo new]有关系。但目前并未发现对App有什么影响,猜想这可能是一个临时的BUG,希望在后续版本中可以修复!


作者:siruoxian
链接:https://www.jianshu.com/p/45d0de1e2cab
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


https://blog.csdn.net/u013410274/article/details/80476258
https://stackoverflow.com/questions/60791763/not-able-to-open-an-app-using-process-in-swift-returns-error-domain-nsposixerr
https://www.5axxw.com/questions/content/n3v7s5

 

 

unused variable warning处理 https://blog.csdn.net/nwpu053883/article/details/103351032

 

 

 

Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option ...  https://blog.csdn.net/qq_22080737/article/details/74332654

 

Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" 

https://www.cnblogs.com/jaxer/p/4812200.html

 

posted @ 2022-06-21 10:53  LiuZX_贤  阅读(1093)  评论(0编辑  收藏  举报