App crashed – Add NSCameraUsageDescription key in info.plist

This morning I found another error and said: “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.”

The error looks just like the below image:

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.

I was trying to build a simple QR code scanner SwiftUI project, but it needs camera access. My code is perfectly fine but still got this error.

In the console, I got that error and the error message is clear to me. Somehow I need to add the NSCameraUsageDescription key and string in my project’s info.plist file.

I am using the latest Xcode, which is Xcode 15. So if I add that key in info.plist it will be good to go.

For those who don’t know how to do this, they can read this tutorial: How to find info.plist file in Xcode in SwiftUI project

Once you get that you just need to click on the “+” sign and add a new row. From the drop-down menu you have to select this option:

 

Add NSCameraUsageDescription

 

For ease of your understanding, I am adding the steps here in this gif

Add NSCameraUsageDescription

If you follow the above step, it will fix your error.

The reason for this error is simple. The app needs permission to access the iPhone’s camera. This will allow the app to request for the camera access.

In the string value: you can use this $(PRODUCT_NAME) camera use

For me, I did not put any value, Xcode automatically fill it for me or just empty will also fine.

Leave a Reply

Your email address will not be published. Required fields are marked *