【iOS工程管理|Crash闪退崩溃】iOS Crash、闪退、崩溃问题汇总(持续更新)

654 阅读2分钟

案例一:[AGXA12Device originalobject]:unrecognized selector

问题描述: 在姿态识别APP中突然出现这个问题: -[AGXA12Device originalobject]: unrecognized selector sent to instance 0x10b80b800

图片.png

原因和解决方案:

原来是摄像头有问题,重启摄像头之后,再去连接又可以了。

案例二:在iPad Air 3上播放本地视频偶现黑屏问题

问题描述: 在iPad air 3上运行体位质控APP偶现播放黑屏的BUG,出现黑屏没有任何报错的信息(bugly),偶现也很难复现,所以极难处理

解决问题:

第一步:让程序自动跑本地视频,跑个几个小时,确实可以复现多次。
第二步:把自己简单封装AVPlayer的播放视频的【GRVideoPlayerView】组件单独拿出来,放到新建的项目里面不断重复播放本地视频,发现出现了黑屏。 那么可以定位就是自己封装的视频组件【GRVideoPlayerView】有问题
第三步:仔细阅读【GRVideoPlayerView】源码,发现replaceCurrentItemWithPlayerItem:该系统api比较可疑,以下是官方api给出的注释:
/*!
	@method			replaceCurrentItemWithPlayerItem:
	@abstract		Replaces the player's current item with the specified player item.
	@param			item
	  The AVPlayerItem that will become the player's current item.
	@discussion
	  In all releases of iOS 4, invoking replaceCurrentItemWithPlayerItem: with an AVPlayerItem that's already the receiver's currentItem results in an exception being raised. Starting with iOS 5, it's a no-op.
	  This method throws an exception if the item already exists in the play queue.
*/
- (void)replaceCurrentItemWithPlayerItem:(nullable AVPlayerItem *)item;

This method throws an exception if the item already exists in the play queue.翻译过来是就是当item已经存在于播放队列时,该方法会抛出异常。

第四步: 使用每次都重新创建Player,替换replaceCurrentItemWithPlayerItem:,replaceCurrentItemWithPlayerItem:该方法阻塞线程
    // 每次都重新创建Player,替换replaceCurrentItemWithPlayerItem:,该方法阻塞线程
    self.player =[AVPlayer playerWithPlayerItem:self.item];
    self.playerLayer =[AVPlayerLayer playerLayerWithPlayer:self.player];
    // 此处为默认视频填充模式
    self.playerLayer.videoGravity = self.videoGravity;
    // 添加playerLayer到self.layer
    [self.layer insertSublayer:self.playerLayer atIndex:0];
第五步:使用每次都重新创建Player的方式,自动跑体位质控软件,跑了4个小时,未发现黑屏

总结: 在播放视频时,为避免出现未知BUG,建议不要使用replaceCurrentItemWithPlayerItem:

案例三:Xcode打包出现Command PhaseScriptExecution failed with a nonzero exit code错误

问题描述:

Xcode打包出现Command PhaseScriptExecution failed with a nonzero exit code的错误提示

详细错误:
/Users/xxx/项目名/Pods/Target Support Files/Pods-项目名/Pods-项目名-frameworks.sh: line 132: ARCHS[@]: unbound variable

Command PhaseScriptExecution failed with a nonzero exit code

图片.png

原因和解决方案:

原因: 项目中残留文件,与项目里面的文件重名,即重复文件

解决方案: 删除项目中多余的文件以及文件夹