從Github上clone了一份開源代碼灭翔,使用了Cocoapods,用的卻是老版的Podfile,參照最新版的Podfile進行了修改之后汞贸,可以運行,但是真機聯(lián)機調(diào)試卻出現(xiàn)App installation failed. An unknown error has occurred. 錯誤印机。
剛開始以為Xcode出問題了矢腻,Clean和刪除Derived Data,重啟Xcode都做了射赛,還是一樣的問題多柑,測試其它項目運行竟然沒有問題,所以可得結(jié)論:此項目一定有問題楣责。
查看Device Log竣灌,有安裝失敗的日志聂沙,但并沒有給出失敗的原因;靈機一動試了一下模擬器運行初嘹,竟能正常啟動及汉,但是一點擊屏幕就出現(xiàn)crash,然后看到日志里提示framework 沒有簽名屯烦,而這個framework是通過CocoaPods生成的豁生,那么可能是Cocoapods相關(guān)的問題嗎?
想把Podfile里use_frameworks!刪掉漫贞,然而項目里使用了@import語法甸箱,刪掉并不妥。
后來再對比了正常項目的Podfile迅脐,發(fā)現(xiàn)我修改的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芍殖,真機運行,居然就好了
參考: