1

EtceteraBinding.promptForPhoto を呼び出すと、iOS 10 ですぐにクラッシュします。

public void TakePhotoTapped() {

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

}

Xcode はこのログを吐き出します。ある種の許可の問題のように見えますか?助けてください。

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.
4

1 に答える 1

2

これは、iOS 10 の新しいプライバシー設定要件に関連しています。個人データへのアクセスを事前に宣言する必要があります。そうしないと、アプリがクラッシュします。

アプリの Info.plist に用途キーを目的の文字列と共に追加するか、すべてのビルドに対して Unity でそれを行うスクリプトを追加できます。

Xcode Info.plist タブ: Info.plist

SO フレームワークごとに、その使用を宣言し、ユーザーに表示される文字列メッセージを入力する必要があります。

Assets/Editor フォルダーに後処理スクリプトを追加して、使用するすべての機能を宣言することもできます。これにより、自動的に 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());
        }
    }
}
于 2016-10-11T10:44:27.453 に答える