iOSでカメラにアクセスする際のInfo.plistの書き方

 

環境

  • Swift
  • Swift3
  • Xcode
  • Xcode9
  • NSMicrophoneUsageDescription
  • Info.plist

エラー内容

[access] 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.

解決方法

info.plistを右クリック -> Open As -> Source Code でソースでかけるようにする

スクリーンショット 2017-10-06 19.27.47.png

下記のようにコピペ

  <key>NSMicrophoneUsageDescription</key>
    <string>Need microphone access for uploading videos</string>
    <key>NSCameraUsageDescription</key>
    <string>Need camera access for uploading Images</string>
    <key>NSLocationUsageDescription</key>
    <string>Need location access for updating nearby friends</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>This app will use your location to show you cool stuff near you.</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>NeedLibrary access for uploading Images</string>

スクリーンショット 2017-10-06 19.28.04.png

元のリストに戻したければ

スクリーンショット 2017-10-06 19.28.17.png

実行

S__10903554.jpg

参考

The app’s Info.plist must contain an NSMicrophoneUsageDescription key with a string value explaining to the user how the app uses this data