iOS10 權限崩潰
出現 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.
解決辦法:
右鍵用 Source Code 形式打開 info.plist 文件,添加對應描述
相機:
<key>NSCameraUsageDescription</key>
<string>此 App 需要你的同意才能使用相機</string>
通訊錄:
<key>NSContactsUsageDescription</key>
<string>此 App 需要你的同意才能使用通訊錄</string>
麥克風:
<key>NSMicrophoneUsageDescription</key>
<string>此 App 需要你的同意才能使用麥克風</string>
相冊:
<key>NSPhotoLibraryUsageDescription</key>
<string>此 App 需要你的同意才能使用相冊</string>
跳轉到App的系統設置
UIApplication.shared.openURL(NSURL(string:UIApplicationOpenSettingsURLString) as! URL)