从Github上clone了一份开源代码,使用了Cocoapods,用的却是老版的Podfile,参照最新版的Podfile进行了修改之后,可以运行,但是真机联机调试却出现App installation failed. An unknown error has occurred. 错误。
刚开始以为Xcode出问题了,Clean和删除Derived Data,重启Xcode都做了,还是一样的问题,测试其它项目运行竟然没有问题,所以可得结论:此项目一定有问题。
查看Device Log,有安装失败的日志,但并没有给出失败的原因;灵机一动试了一下模拟器运行,竟能正常启动,但是一点击屏幕就出现crash,然后看到日志里提示framework 没有签名,而这个framework是通过CocoaPods生成的,那么可能是Cocoapods相关的问题吗?
想把Podfile里use_frameworks!删掉,然而项目里使用了@import语法,删掉并不妥。
后来再对比了正常项目的Podfile,发现我修改的Podfile里少了下面几行:
if defined? installer_representation.project
post_install do |installer_representation|
installer_representation.project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ARCHS'] = 'armv7 arm64'
config.build_settings['VALID_ARCHS'] = 'armv7 arm64'
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
end
end
if defined? installer_representation.pods_project
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ARCHS'] = 'armv7 arm64'
config.build_settings['VALID_ARCHS'] = 'armv7 arm64'
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
end
end
再重新pod install,真机运行,居然就好了
参考: