最近在做一個項目的更新上架,上傳到蘋果審核,因為啟動時候會崩潰導致被拒。我在本地進行測試時,都沒有問題。(事后發現我只有用iOS 10一下版本進行測試,沒有進行測試iOS 10真機)前后左右折騰了一段時間,期間也搭建過ipv6環境進行測試,最后發現是在iOS 10系統的權限出現問題。
首先,先看一下蘋果發過來的crash log
???完全看不懂,都是一些內存地址,我試過使用symbolicatecrash進行解析,仍然是一些內存地址,完全定位不到具體的崩潰函數。
我仔細看了蘋果審核發過來的信息
Your app crashes on iPad running iOS 10.2.1 when we:
launch the app
Next Steps
Please review your app on iPad to ensure that it runs without crashing. Also, please follow the steps to reproduce the issue when running your app on iPad configured for real world use.
For new apps, uninstall all previous versions of your app from a device, then install and follow the steps to reproduce. For updates, install the new version as an update to the previous version, then install and follow the steps to reproduce.
意思是說,我的應用在運行在ipad(iOS 10.2.1)上面,啟動時候會發生閃退的情況。下面說了,解決的建議。。
剛開始我以為可能是ipad的布局問題導致的閃退,特定拿了ipad的模擬器(沒有ipad)進行測試,沒有問題,之后,更新了afn,搭建ipv6環境進行測試,都是沒有問題的。我才意識到,我的應用還沒有在iOS 10.2.1上面進行測試。于是,我更新了iphone系統,進行測試,居然崩潰了!報了以下錯誤:
This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSMicrophoneUsageDescription key with a string value explaining to the user how the app uses this data.
原來是iOS 10系統的權限問題導致的崩潰,汗??,之后的解決方法就很簡單了。只需要在info.plist文件中,添加即可。
這里也提供一下其他的權限key,如果你在應用中有使用其中的功能,不要忘記添加這些key哦。
<key>NSCameraUsageDescription</key>
<string>cameraDesciption</string>
<key>NSContactsUsageDescription</key>
<string>contactsDesciption</string>
<key>NSMicrophoneUsageDescription</key>
<string>microphoneDesciption</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>LibraryUsageDescription</string>