您现在的位置: IOS教程網 >> IOS系統 >  >> iOS 程式開發 >> iOS 開發綜合

iOS 10 權限崩潰問題詳解與解決方案

編輯:iOS 開發綜合

iOS 10 權限崩潰問題

今天手機升級到 iOS 10 Beta,然後把正在開發的專案裝了個 ipa 包,發現一點擊涉及權限訪問的功能就直接 Crash 了,並在控制台輸出了以下資訊:

This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSContactsUsageDescription key with a string value explaining to the user how the app uses this data.

也就是說:你需要在 Info.plist 中新增一個「NSContactsUsageDescription」的 Key,並為它加上一段描述文字作為 Value。

1、在專案中找到 Info.plist,右鍵選擇 Open As,以 Source Code 形式打開;
2、分別複製以下 Value 與 Key,Key 一定不能出錯,Value 大致上可以隨意填寫。

相機權限描述:

<key>NSCameraUsageDescription</key>
    <string>cameraDesciption</string>

通信錄:

<key>NSContactsUsageDescription</key>
    <string>contactsDesciption</string>

麥克風:

<key>NSMicrophoneUsageDescription</key>
    <string>microphoneDesciption</string>

相簿:

<key>NSPhotoLibraryUsageDescription</key>
    <string>photoLibraryDesciption</string>

其他權限描述,debug 控制台都會有輸出,自行補上即可。

3、在 Info.plist 中貼上,然後存檔,如下圖:

Source Code 形式:

Property List 的呈現形式:

4、Clean 之後運行即可。

感謝閱讀,希望能幫助到你,謝謝你對本站的支持!

  1. 上一篇文章:
  2. 下一篇文章:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © IOS教程網 All Rights Reserved