Search Unity

Where Can I Add NSCameraUsageDescription persmission?

Discussion in 'Unity Build Automation' started by alexandros356, Dec 13, 2016.

  1. alexandros356

    alexandros356

    Joined:
    Dec 3, 2012
    Posts:
    105
    Hi guys,

    I'm using Unity 5.5.0 f3 with Vuforia on Windows 10. I'm using the Unity Cloud to build for iOS.
    When I try to test the app in my ipad it crashes and this is what appears in the log.

    Termination Reason: TCC, 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 can't find where to add the permission. If I have to do it in the Unity Editor or in the Unity Cloud.

    Could you help me?
    Thanks in advance
     
  2. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    You will need to modify the Info.plist in a post-export step (either using PostProcessBuildAttribute or configuring a custom post-export method in your Unity Cloud Build target configuration).

    The docs for the plist portion of the Xcode API are here: http://docs.unity3d.com/ScriptReference/iOS.Xcode.PlistDocument.html

    Here is an example of how you would add that value at build time using a PostProcessBuildAttribute (which should work both locally and in UCB):
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using UnityEditor.Callbacks;
    4. using UnityEditor.iOS.Xcode;
    5. using System.IO;
    6. using System.Collections.Generic;
    7.  
    8. public class CloudBuildHelper : MonoBehaviour
    9. {
    10. #if UNITY_IOS
    11.     [PostProcessBuild]
    12.     static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    13.     {
    14.         // Read plist
    15.         var plistPath = Path.Combine(path, "Info.plist");
    16.         var plist = new PlistDocument();
    17.         plist.ReadFromFile(plistPath);
    18.  
    19.         // Update value
    20.         PlistElementDict rootDict = plist.root;
    21.         rootDict.SetString("NSCameraUsageDescription", "Used for taking selfies");
    22.  
    23.         // Write plist
    24.         File.WriteAllText(plistPath, plist.WriteToString());
    25.     }
    26. #endif
    27. }
    Note that script will need to be in an Editor/ folder inside your project.
     
  3. Morgondag

    Morgondag

    Joined:
    Dec 29, 2014
    Posts:
    35
  4. affinixy

    affinixy

    Joined:
    Nov 2, 2017
    Posts:
    13
    Hi Danny, I am trying to use this example to setup for iOS14, NSUserTrackingUsageDescription key in the Info.plist file via Cloud Build.

    Do I need to add the method. Eg:
    "CloudBuildHelper.OnPostprocessBuild"
    in CloudBuild>Advanced Options>Post-Export Method

    Or this script should run by itself when i do a cloud build.
    Please advise.
    Thanks
     
  5. Deleted User

    Deleted User

    Guest

    @dannyd I'm using the localization package 1.3.2 and it seems that it's still required to manually add the NSCameraUsageDescription key to the info.plist.

    When will this be part of the process automatically? I mean why am I creating the translations for the camera when they are not added automatically?
     
    Last edited by a moderator: May 17, 2023
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,292
    Have you tried 1.4.3? If it's not visible in the package manager you may need to edit the manfiest.json file in the packages folder. If this is still an issue please file a bug report so we can look into it.
     
  7. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    I am getting rejected because of this in Unity 2023.1.10
    Is there a solution?
    I only use the mic, but if I leave out the camera description in the Unity build it crashes on device testing in Testflight because
    "exception" : {"codes":"0x0000000000000000, 0x0000000000000000","rawCodes":[0,0],"type":"EXC_CRASH","signal":"SIGABRT"},
    "termination" : {"flags":518,"code":0,"namespace":"TCC","details":["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."]},
    "faultingThread" : 2,
    "threads" : [{"id":143565,"queue":"com.apple.main-

    If I fill in the Camera description with something like "Camera not used' it runs fine on Testflight, but then gets rejected by the appstore review team for a privacy violation for not explaining what the camera is used for.
    They're not interested it's a Unity bug/issue.

    I notice in the XCode project classes/Unity CameraCapture is included but I don't use Camera at all.

    I'm wondering if it's related to screen orientation as discussed here: https://discussions.unity.com/t/why...oject-is-trying-to-access-the-camera/174649/2