プログラミングスクール最大70%OFF! ←クリックして見に行く

【Error】[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 NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.

【Error】[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 NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.

エラー解消方法の備忘録_φ(・_・ )

発生したエラー

[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 NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.

翻訳

[アクセス]このアプリは、使用方法の説明がないままプライバシーに敏感なデータにアクセスしようとしたため、クラッシュしました。
アプリのInfo.plistにNSCameraUsageDescriptionキーと、アプリがこのデータをどのように使用するかをユーザーに説明するための文字列値を含める必要があります。

原因

UIImagePickerController でカメラを作成した場合、
Info.plist にカメラを起動する理由を記載しないと
Thread 8: signal SIGABRTのようなエラーが出てアプリが落ちます。

Point

アルバム(カメラロール)にアクセスする時も同様で、
Info.plistで使用目的を記載しないと同じようなエラーになります。

解決手順

・Info.plistに1行追加する
①Project Navigatorを開く
②Info.plistを選択
③INformation Property List 項目の右にあるプラスボタンをクリック

・カメラの使用用途を明示する
①Key(左側)に Privacy – Camera Usage Description と入力、またはプルダウンから選択
②Value(右側)に使用する目的を入力。

Point

今回はバーコード読み取りにカメラを使用するので以下を使用する理由として記載しましたが、
それぞれのアプリの使用用途を記載しましょう!
「Permission is required to read the barcode.」

参考サイト

なし

Swiftカテゴリの最新記事