今天 手機更新了 iOS10 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 貌似可以随便填寫
相機權限描述:
NSCameraUsageDescription
cameraDesciption
通信錄:
NSContactsUsageDescription
contactsDesciption
麥克風:
NSMicrophoneUsageDescription
microphoneDesciption
相機:
NSPhotoLibraryUsageDescription
photoLibraryDesciption
eg:其他權限描述,debug 控制台都會有輸出的,自行添加就OK
3,在info.plist 檔案上 複制上,然後 儲存,如下圖:
Source Code 的形式:
<key>NSCameraUsageDescription</key>
<string>cameraDesciption</string>
<key>NSContactsUsageDescription</key>
<string>contactsDesciption</string>
<key>NSMicrophoneUsageDescription</key>
<string>microphoneDesciption</string>
Property List 的展現形式:

4,Clean之後,運作就OK了