crash问题汇集

1, 项目里含有P3资源图片,导致线上环境iOS9.X会crash. 图片都是设计师提供的,是不是P3格式图片平时很难会关注这个,都是提供什么就用什么(只要测的时候能显示正常就不会去考虑去把机型一一测个遍了),这个坑爹的问题...
ERROR ITMS-90682: Invalid Bundle - The asset catalog at 'Payload/XXXXX/Assets.car' can't contain 16-bit or P3 assets if the app supports iOS 8 or earlier

查找及定位方式:
https://www.jianshu.com/p/97add04998ef
https://stackoverflow.com/questions/39404285/xcode-8-build-crash-on-ios-9-2-and-below

2, 崩溃日志里记录
CALayerInvalidGeometry
CALayer position contains NaN: [110 nan]......
其崩溃的原因就是在View.frame 中计算时,有的地方除以0了,经过定位,发现项目中有段代码如下:

    UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.model.img_url]]];
    UIImageView *adImageView = [[UIImageView alloc] init];
    adImageView.width =100;
    adImageView.height = image.size.height / image.size.width*adImageView.width;
    adImageView.left = (TotalWidth - adImageView.width)/2;
    adImageView.top = (TotalHeight - adImageView.height)/2;

由于image.size.width为0,导致了crash. 修改后正常。

相关链接: https://www.jianshu.com/p/0842b4a09bf5

3, 遇到此crash: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'

是因为向字典里插入nil值。举例,请求接口数据时,请求参数需要传userID, 如下:

NSDictionary *parameters = @{@"user_ids": userId};

如果userId在请求时还未获取到,那么这样给字典的value赋值nil 就会crash。解决方式之一:

NSMutableDictionary *parameters = @{}.mutableCopy;
parameters[@"user_ids"] = userId;

后续慢慢更新~

你可能感兴趣的:(crash问题汇集)