1

Calling EtceteraBinding.promptForPhoto resulting in immediate crash on iOS 10.

public void TakePhotoTapped() {

    #if UNITY_IOS
    EtceteraBinding.promptForPhoto(0.2f, PhotoPromptType.Camera, 0.8f, true);
    #endif

}

Xcode spits out this log. It does look like some sort of permission issue? Please help.

2016-10-11 11:46:35.758167 xxx[1643:458841] invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.
2016-10-11 11:46:49.760643 xxx[1643:458841] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2016-10-11 11:46:49.768609 xxx[1643:458841] [MC] Reading from public effective user settings.
2016-10-11 11:47:02.450381 xxx[1643:459135] [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.
Greg Lukosek
  • 1,774
  • 20
  • 40
  • Post the stacktrace. – Droppy Oct 11 '16 at 10:33
  • It is self explanatory in the logs, add the key `NSCameraUsageDescription` key with `Using Camera to capture photo` in the `info.plist`. It is now mandatory from the apple that you need to provide an explanation for your usage in info.plist. – Sachin Vas Oct 11 '16 at 10:35
  • This will require manual edit in xcode after every build from Unity. Something definitely need to avoid as it will disable this project from being used in Unity Cloud Build – Greg Lukosek Oct 11 '16 at 10:36

1 Answers1

2

This is related to new iOS 10 Privacy Settings requirement. You must declare ahead of time any access to private data or your App will crash.

You can add a usage key to your app’s Info.plist together with a purpose string or add a script that will do it for you in Unity for all your builds.

Xcode Info.plist tab: Info.plist

SO for each framework you have to declare it's use and enter a string message that is shown to the user.

You can also add a post processing script in your Assets/Editor folder, where you declare all features used - this will automatically add them to Info.plist:

using UnityEngine;
using UnityEditor;
using System.Collections;
using UnityEditor.Callbacks;
using System.Collections;
using System.IO;
using UnityEditor.iOS.Xcode;


public class ChangeIOSplistFile : MonoBehaviour {

    [PostProcessBuild]
    public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject) {

        if (buildTarget == BuildTarget.iOS) {

            // Get plist
            string plistPath = pathToBuiltProject + "/Info.plist";
            PlistDocument plist = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));

            // Get root
            PlistElementDict rootDict = plist.root;
            var cameraKey = "NSCameraUsageDescription";
            rootDict.CreateDict (cameraKey);
            rootDict.SetString (cameraKey, "Enter your description here.");

            var galleryKey = "NSPhotoLibraryUsageDescription";
            rootDict.CreateDict (galleryKey);

            rootDict.SetString (galleryKey, "Enter your description here.");

            // Write to file
            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
}