Programing

iOS 10.0 런타임 충돌의 NSCameraUsageDescription?

lottogame 2020. 6. 14. 10:20
반응형

iOS 10.0 런타임 충돌의 NSCameraUsageDescription?


iOS 10.0마지막 베타 사용 앱에서 바코드를 스캔하기 위해 카메라를 사용하려고했는데이 런타임 오류로 인해 충돌이 발생했습니다.

사용법에 대한 설명없이 개인 정보에 민감한 데이터에 액세스하려고했기 때문에이 앱이 다운되었습니다. 앱의 Info.plist에는 앱이이 데이터를 사용하는 방법을 사용자에게 설명하는 문자열 값이있는 NSCameraUsageDescription 키가 포함되어야합니다.

이 키를 plist에 넣었지만 여전히 추락 했습니까?


iOS 10 이후에는 아래와 같이 Info.plist에서 앱이 액세스하는 모든 시스템의 개인 정보 보호 데이터에 대한 사용법 설명을 정의하고 제공해야합니다.

달력

Key    :  Privacy - Calendars Usage Description    
Value  :  $(PRODUCT_NAME) calendar events

알림 :

Key    :   Privacy - Reminders Usage Description    
Value  :   $(PRODUCT_NAME) reminder use

연락 :

Key    :   Privacy - Contacts Usage Description     
Value  :  $(PRODUCT_NAME) contact use

사진 :

Key    :  Privacy - Photo Library Usage Description    
Value  :  $(PRODUCT_NAME) photo use

블루투스 공유 :

Key    :  Privacy - Bluetooth Peripheral Usage Description     
Value  :  $(PRODUCT_NAME) Bluetooth Peripheral use

마이크 :

Key    :  Privacy - Microphone Usage Description    
Value  :  $(PRODUCT_NAME) microphone use

카메라 :

Key    :  Privacy - Camera Usage Description   
Value  :  $(PRODUCT_NAME) camera use

위치 :

Key    :  Privacy - Location Always Usage Description   
Value  :  $(PRODUCT_NAME) location use

Key    :  Privacy - Location When In Use Usage Description   
Value  :  $(PRODUCT_NAME) location use

히스 :

Key    :  Privacy - Health Share Usage Description   
Value  :  $(PRODUCT_NAME) heath share use

Key    :  Privacy - Health Update Usage Description   
Value  :  $(PRODUCT_NAME) heath update use

홈킷 :

Key    :  Privacy - HomeKit Usage Description   
Value  :  $(PRODUCT_NAME) home kit use

미디어 라이브러리 :

Key    :  Privacy - Media Library Usage Description   
Value  :  $(PRODUCT_NAME) media library use

모션 :

Key    :  Privacy - Motion Usage Description   
Value  :  $(PRODUCT_NAME) motion use

음성 인식 :

Key    :  Privacy - Speech Recognition Usage Description   
Value  :  $(PRODUCT_NAME) speech use

시리 킷 :

Key    :  Privacy - Siri Usage Description  
Value  :  $(PRODUCT_NAME) siri use

TV 제공 업체 :

Key    :  Privacy - TV Provider Usage Description   
Value  :  $(PRODUCT_NAME) tvProvider use

You can get detailed information in this link.


As Apple has changed how you can access any user private data types in iOS 10.

You need to add the "Privacy - Camera usage description" key to your app’s Info.plist and their usage information which is apply for your application, as in below example I had provided that I have used to scan barcodes.

For more information please find the below screenshot.

enter image description here


You have to add this below key in info.plist.

NSCameraUsageDescription Or Privacy - Camera usage description

And add description of usage.

Detailed screenshots are available in this link


Alternatively open Info.plist as source code and add this:

<key>NSCameraUsageDescription</key>
<string>Camera usage description</string>

Use these raw values and copy in info.plist

    <key>NSCalendarsUsageDescription</key>
      <string>$(PRODUCT_NAME) calendar events</string>
    <key>NSRemindersUsageDescription</key>
      <string>$(PRODUCT_NAME) reminder use</string>
    <key>NSCameraUsageDescription</key>
      <string>This app requires to access your photo library to show image on profile and send via chat</string>
    <key>NSMicrophoneUsageDescription</key>
      <string>This app requires to access your microphone to record video with your voice send via chat</string>
    <key>NSPhotoLibraryUsageDescription</key>
      <string>This app requires to access your photo library to show image on profile and send via chat</string>
    <key>NSContactsUsageDescription</key>
       <string>$(PRODUCT_NAME) contact use</string>
    <key>NSLocationAlwaysUsageDescription</key>
      <string>$(PRODUCT_NAME) location use</string>
    <key>NSLocationWhenInUseUsageDescription</key>
      <string>$(PRODUCT_NAME) location use</string>

the xcode UI has changed a bit from one version to the next so here is where you update the plist for 9.0 beta 4 if it helps Project ->Target ->Infoenter image description here


Another instance that I faced while trying to use the camera, was that it was still busy crashing giving same _CRASHING_DUE_TO_PRIVACY even after adding the "Camera Usage Description". After failing to get anything tangible from the call stack, switched to the "Organizer" and looked into the crash reports on the device. I found that it was in fact complaining about the privacy due to the missing "Microphone Usage Description". I added that and got rid of such a cryptic break down.


For those who are still getting the error even though you added proper keys into Info.plist:

Make sure you are adding the key into correct Info.plist. Newer version of xCode, apparently has 3 Info.plist.

One is under folder with your app's name which solved problem for me.

Second is under YourappnameTests and third one is under YourappnameUITests.

Hope it helps.


If you're using Ionic, you can solve it directly from config.xml by adding inside platform ios tag:

<platform name="ios">
.
.
.
    <config-file target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
        <string>photo library usage description</string>
    </config-file>
    <config-file target="*-Info.plist" parent="NSCameraUsageDescription">
        <string>camera usage description</string>
    </config-file>
.
.
.
</platform>

I'd like to thank @BHUPI answer too.


You do this by adding a usage key to your app’s Info.plist together with a purpose string. NSCameraUsageDescription Specifies the reason for your app to access the device’s camera

https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html


I checked the plist and found it is not working, only in the "project" info, you need to add the "Privacy - Camera ....", then it should work. Hope to help you.

참고URL : https://stackoverflow.com/questions/39465687/nscamerausagedescription-in-ios-10-0-runtime-crash

반응형