public static void SetXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
    {
        if (buildTarget != BuildTarget.iOS)
        {
            return;
        }

        var plistPath = pathToBuiltProject + "/Info.plist";
        var plist     = new PlistDocument();

        plist.ReadFromString(File.ReadAllText(plistPath));

        var rootDict = plist.root;

        // ここに記載したKey-ValueがXcodeのinfo.plistに反映されます
        rootDict.SetString("UIStatusBarStyle", "UIStatusBarStyleLightContent");

        rootDict.SetString("NSBluetoothAlwaysUsageDescription", "別の端末にデータを送信する為にBluetoothを使用します");
        File.WriteAllText(plistPath, plist.WriteToString());
    }
示例#2
0
    public static void AddBluetoothUsageKey(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;

            // Ensure that photo usage description is always added
            var buildKey = "NSBluetoothPeripheralUsageDescription";
            rootDict.SetString(buildKey, "Advertisement would like to use bluetooth");

            // Write to file
            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
    public static void OnPostprocessBuild(BuildTarget target, string buildPath)
    {
        if (target != BuildTarget.iOS)
        {
            return;
        }

        string plistPath = Path.Combine(buildPath, "Info.plist");

        PlistDocument plist = new PlistDocument();

        plist.ReadFromString(File.ReadAllText(plistPath));

        PlistElementDict  rootDict = plist.root;
        PlistElementArray LSApplicationQueriesSchemes = rootDict.CreateArray("LSApplicationQueriesSchemes");

        LSApplicationQueriesSchemes.AddString("bankid");

        File.WriteAllText(plistPath, plist.WriteToString());
    }
示例#4
0
    public static void AddPhotoLibraryUsageKey(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;

            // Ensure that photo usage description is always added
            var buildKey = "NSPhotoLibraryUsageDescription";
            rootDict.SetString(buildKey, "Photo library access needed to save screenshots");

            // Write to file
            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
示例#5
0
    public static void OnPostProcessBuild(BuildTarget buildTarget, string buildPath)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            var projPath = buildPath + "/Unity-Iphone.xcodeproj/project.pbxproj";
            var proj     = new PBXProject();
            proj.ReadFromFile(projPath);

            var targetGuid = proj.TargetGuidByName(PBXProject.GetUnityTargetName());


            proj.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");
            proj.SetBuildProperty(targetGuid, "SWIFT_OBJC_BRIDGING_HEADER", "Libraries/Plugins/iOS/JuniperPlugin/Source/JuniperPlugin-Bridging-Header.h");
            proj.SetBuildProperty(targetGuid, "SWIFT_OBJC_INTERFACE_HEADER_NAME", "JuniperPlugin-Swift.h");
            proj.AddBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "@executable_path/Frameworks $(PROJECT_DIR)/lib/$(CONFIGURATION) $(inherited)");
            proj.AddBuildProperty(targetGuid, "FRAMERWORK_SEARCH_PATHS",
                                  "$(inherited) $(PROJECT_DIR) $(PROJECT_DIR)/Frameworks");
            proj.AddBuildProperty(targetGuid, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
            proj.AddBuildProperty(targetGuid, "DYLIB_INSTALL_NAME_BASE", "@rpath");
            proj.AddBuildProperty(targetGuid, "LD_DYLIB_INSTALL_NAME",
                                  "@executable_path/../Frameworks/$(EXECUTABLE_PATH)");
            proj.AddBuildProperty(targetGuid, "DEFINES_MODULE", "YES");
            proj.AddBuildProperty(targetGuid, "SWIFT_VERSION", "4.0");
            proj.AddBuildProperty(targetGuid, "COREML_CODEGEN_LANGUAGE", "Swift");

            proj.WriteToFile(projPath);

            //get plist
            string        plistPath = buildPath + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));
            PlistElementDict rootDict = plist.root;

            //add external accessory string for the juniper geode gps
            PlistElementArray externals = rootDict.CreateArray("UISupportedExternalAccessoryProtocols");
            externals.AddString("com.junipersys.geode");

            //write to file to save changes
            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
示例#6
0
        public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
        {
                        #if UNITY_IOS
            if (shouldRun && buildTarget == BuildTarget.iOS)
            {
                // Get plist
                string        plistPath = pathToBuiltProject + "/" + nameOfPlist;
                PlistDocument plist     = new PlistDocument();
                plist.ReadFromString(File.ReadAllText(plistPath));

                // Get root
                PlistElementDict rootDict = plist.root;

                rootDict.SetString(keyForMicrophoneUsage, microphoneUsageDescription);
                rootDict.SetString(keyForSpeechRecognitionUsage, speechRecognitionUsageDescription);

                // Write to file
                File.WriteAllText(plistPath, plist.WriteToString());
            }
                        #endif
        }
    public static void OnPostprocessBuild(BuildTarget target, string buildPath)
    {
        if (!ENABLED)
        {
            return;
        }

        if (target == BuildTarget.iOS)
        {
            string plistPath = Path.Combine(buildPath, "Info.plist");

            PlistDocument plist = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));

            PlistElementDict rootDict = plist.root;
            rootDict.SetString("NSPhotoLibraryUsageDescription", PHOTO_LIBRARY_USAGE_DESCRIPTION);
            rootDict.SetString("NSPhotoLibraryAddUsageDescription", PHOTO_LIBRARY_USAGE_DESCRIPTION);

            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
示例#8
0
    private static void EditorPlist(string plistPath)
    {
        string        infoPath = plistPath + "/info.plist";
        PlistDocument info     = new PlistDocument();

        info.ReadFromString(File.ReadAllText(infoPath));

        info.root.SetBoolean("ITSAppUsesNonExemptEncryption", false);
        info.root.SetString("NSCameraUsageDescription", "App需要使用您的相机");
        info.root.SetString("NSMicrophoneUsageDescription", "App需要使用您的麦克风");

        PlistElementArray addArray = info.root.CreateArray("LSApplicationQueriesSchemes");

        addArray.AddString("weixin");
        addArray.AddString("wechat");
        addArray.AddString("wtloginmqq2");
        addArray.AddString("mqqopensdkapiV3");
        addArray.AddString("mqqwpa");

        File.WriteAllText(infoPath, info.WriteToString());
    }
    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;

            rootDict.SetString("NSBluetoothPeripheralUsageDescription", "Uses BLE to communicate with devices.");
            rootDict.SetString("NSCameraUsageDescription", "Uses the camera to spy on your neighbors.");
            rootDict.SetString("NSMicrophoneUsageDescription", "Uses the microphone to spy on your neighbors.");
            rootDict.SetString("NSPhotoLibraryAddUsageDescription", "Drops malware into your documents.");

            // Write to file
            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
    private static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
    {
        // Get plist
        string        plistPath = pathToBuiltProject + "/Info.plist";
        PlistDocument plist     = new PlistDocument();

        plist.ReadFromString(File.ReadAllText(plistPath));

        // Get root
        PlistElementDict rootDict = plist.root;

        // Set value of NSLocationAlwaysUsageDescription in Xcode plist
        var buildKey = "NSLocationAlwaysUsageDescription";

        rootDict.SetString(buildKey, "Just to show");
        buildKey = "NSLocationAlwaysAndWhenInUseUsageDescription";
        rootDict.SetString(buildKey, "Just to show");

        // Write to file
        File.WriteAllText(plistPath, plist.WriteToString());
    }
示例#11
0
        public static void OnPostprocessBuild(BuildTarget target, string buildPath)
        {
            if (!Settings.Instance.AutomatedSetup)
            {
                return;
            }

            if (target == BuildTarget.iOS)
            {
                string plistPath = Path.Combine(buildPath, "Info.plist");

                PlistDocument plist = new PlistDocument();
                plist.ReadFromString(File.ReadAllText(plistPath));

                PlistElementDict rootDict = plist.root;
                rootDict.SetString("NSPhotoLibraryUsageDescription", Settings.Instance.PhotoLibraryUsageDescription);
                rootDict.SetString("NSPhotoLibraryAddUsageDescription", Settings.Instance.PhotoLibraryUsageDescription);

                File.WriteAllText(plistPath, plist.WriteToString());
            }
        }
    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;

            // Change value of CFBundleVersion in Xcode plist
            var Key   = "NSPhotoLibraryUsageDescription";
            var Value = "Save screenshots";
            rootDict.SetString(Key, Value);

            // Write to file
            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
示例#13
0
    public static void DisableAllowArbitraryLoads(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;

            PlistElementDict appTransportSecurity = rootDict.CreateDict("NSAppTransportSecurity");

            // enable app transport
            appTransportSecurity.SetBoolean("NSAllowsArbitraryLoads", false);

            // Write to file
            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
示例#14
0
        private static void UpdateIOSPlist(string path)
        {
#if UNITY_IOS
            string plistPath = Path.Combine(path, "Info.plist");

            PlistDocument plist = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));


            //Get Root
            PlistElementDict rootDict = plist.root;


            PlistElementString calendarPrivacy = (PlistElementString)rootDict["NSCalendarsUsageDescription"];
            if (calendarPrivacy == null)
            {
                rootDict.SetString("NSCalendarsUsageDescription", "Some ad content may create a calendar event.");
            }

            PlistElementString photoPrivacy = (PlistElementString)rootDict["NSPhotoLibraryUsageDescription"];
            if (photoPrivacy == null)
            {
                rootDict.SetString("NSPhotoLibraryUsageDescription", "Some ad content may require access to the photo library.");
            }

            PlistElementString cameraPrivacy = (PlistElementString)rootDict["NSCameraUsageDescription"];
            if (cameraPrivacy == null)
            {
                rootDict.SetString("NSCameraUsageDescription", "Some ad content may access camera to take picture.");
            }

            PlistElementString motionPrivacy = (PlistElementString)rootDict["NSMotionUsageDescription"];
            if (motionPrivacy == null)
            {
                rootDict.SetString("NSMotionUsageDescription", "Some ad content may require access to accelerometer for interactive ad experience.");
            }

            File.WriteAllText(plistPath, plist.WriteToString());
#endif
        }
示例#15
0
    public static void OnPostProcessBuild(BuildTarget target, string path)
    {
        if (target != BuildTarget.iOS)
        {
            return;
        }

        string projPath = Path.Combine(path, "Unity-iPhone.xcodeproj/project.pbxproj");

        // automatically @include frameworks and disable bitcode
        PBXProject proj = new PBXProject();
        string     file = File.ReadAllText(projPath);

        proj.ReadFromString(file);

        string targetGuid = proj.TargetGuidByName("Unity-iPhone");

        proj.SetBuildProperty(targetGuid, "CLANG_ENABLE_MODULES", "YES");
        proj.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");

        File.WriteAllText(projPath, proj.WriteToString());

        // add necessary permissions to Plist
        string        plistPath = Path.Combine(path, "Info.plist");
        PlistDocument plist     = new PlistDocument();

        plist.ReadFromString(File.ReadAllText(plistPath));

        PlistElementDict rootDict = plist.root;

        rootDict.SetString("NSPhotoLibraryUsageDescription", "Requires access to the Photo Library");
        rootDict.SetString("NSPhotoLibraryAddUsageDescription", "Requires access to the Photo Library");
        rootDict.SetString("NSCameraUsageDescription", "Requires access to the Camera");
        rootDict.SetString("NSContactsUsageDescription", "Requires access to Contacts");
        rootDict.SetString("NSLocationAlwaysUsageDescription", "Requires access to Location");
        rootDict.SetString("NSLocationWhenInUseUsageDescription", "Requires access to Location");
        rootDict.SetString("NSLocationAlwaysAndWhenInUseUsageDescription", "Requires access to Location");

        File.WriteAllText(plistPath, plist.WriteToString());
    }
        private static void UpdateProjectPlist(BuildTarget buildTarget, string plistPath)
        {
#if UNITY_IOS
            PlistDocument plist = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));
            PlistElementDict root         = plist.root;
            var applicationQueriesSchemes = plist.root["LSApplicationQueriesSchemes"] != null ? plist.root["LSApplicationQueriesSchemes"].AsArray() : null;
            if (applicationQueriesSchemes == null)
            {
                applicationQueriesSchemes = plist.root.CreateArray("LSApplicationQueriesSchemes");
            }
            foreach (var scheme in new[] { "fb", "instagram", "tumblr", "twitter" })
            {
                if (applicationQueriesSchemes.values.Find(x => x.AsString() == scheme) == null)
                {
                    applicationQueriesSchemes.AddString(scheme);
                }
            }
            foreach (var kvp in new[] {
                new []
                { "NSCalendarsUsageDescription", "Some ad content may create a calendar event." }
                ,
                new []
                { "NSPhotoLibraryUsageDescription", "Some ad content may require access to the photo library." }
                ,
                new []
                { "NSCameraUsageDescription", "Some ad content may access camera to take picture." }
                ,
                new []
                { "NSMotionUsageDescription", "Some ad content may require access to accelerometer for interactive ad experience." }
            })
            {
                if (!root.values.ContainsKey(kvp[0]))
                {
                    root.SetString(kvp[0], kvp[1]);
                }
            }
            File.WriteAllText(plistPath, plist.WriteToString());
#endif
        }
示例#17
0
        private static void UpdateInfoPlist(BuildInfo buildInfo)
        {
#if UNITY_IOS
            Debug.Log("[ReplayKit] Updating info.plist.");

            // open plist
            string        plistPath = buildInfo.Path + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));
            PlistElementDict rootDict = plist.root;

            // add usage permissions
            Dictionary <string, string> permissions = GetUsagePermissions();
            foreach (string key in permissions.Keys)
            {
                rootDict.SetString(key, permissions[key]);
            }

            // save changes to file
            File.WriteAllText(plistPath, plist.WriteToString());
#endif
        }
    public static void OnPostprocessBuild(BuildTarget buildTarget, string pathToBuiltProject)
    {
#if UNITY_IOS
        // Get plist
        string        plistPath = pathToBuiltProject + "/Info.plist";
        PlistDocument plist     = new PlistDocument();
        plist.ReadFromString(File.ReadAllText(plistPath));

        // Get root
        PlistElementDict rootDict = plist.root;

        // remove exit on suspend if it exists.
        string exitsOnSuspendKey = "UIApplicationExitsOnSuspend";
        if (rootDict.values.ContainsKey(exitsOnSuspendKey))
        {
            rootDict.values.Remove(exitsOnSuspendKey);
        }

        // Write to file
        File.WriteAllText(plistPath, plist.WriteToString());
#endif
    }
        public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
        {
            if (buildTarget == BuildTarget.iOS)
            {
                string     pbxProjectPath = PBXProject.GetPBXProjectPath(path);
                PBXProject pbxProject     = new PBXProject();
                pbxProject.ReadFromString(File.ReadAllText(pbxProjectPath));
#if UNITY_2019_3_OR_NEWER
                string targetGuid = pbxProject.GetUnityMainTargetGuid();
#else
                string targetGuid = pbxProject.TargetGuidByName("Unity-iPhone");
#endif

                // Framework Embed
                const string relativeFrameworkFolder = "Library/Oqupie/SDK/iOS";
                const string frameworkName           = "OqupieSupportSDK.framework";
                string       frameworkPath           = Path.Combine(relativeFrameworkFolder, frameworkName);
                string       fileGuid = pbxProject.AddFile(frameworkPath, "Frameworks/" + frameworkPath, PBXSourceTree.Sdk);
                pbxProject.AddFileToEmbedFrameworks(targetGuid, fileGuid);
                pbxProject.SetBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks");

                // PBXProject 저장
                pbxProject.WriteToFile(pbxProjectPath);

                // plist 수정
                string        plistPath = path + "/Info.plist";
                PlistDocument plist     = new PlistDocument();
                plist.ReadFromString(File.ReadAllText(plistPath));
                PlistElementDict rootDict = plist.root;

                // Privacy - Photo Library Usage Description
                rootDict.SetString("NSPhotoLibraryUsageDescription", "This app needs to use photo library for file attachment");
                // Privacy - Camera Usage Description
                rootDict.SetString("NSCameraUsageDescription", "This app needs to use camera for file attachment");

                // plist 저장
                File.WriteAllText(plistPath, plist.WriteToString());
            }
        }
    private static void BuildForiOS(string path, UMPSettings settings)
    {
#if UNITY_IPHONE
        var projPath   = Path.Combine(path, "Unity-iPhone.xcodeproj/project.pbxproj");
        var pbxProject = new PBXProject();
        pbxProject.ReadFromString(File.ReadAllText(projPath));

        var target = pbxProject.TargetGuidByName("Unity-iPhone");

        // Activate Background Mode for Audio
        string        plistPath = path + "/Info.plist";
        PlistDocument plist     = new PlistDocument();
        plist.ReadFromString(File.ReadAllText(plistPath));

        PlistElementDict rootDict = plist.root;
        var buildKey = "UIBackgroundModes";
        rootDict.CreateArray(buildKey).AddString("audio");
        File.WriteAllText(plistPath, plist.WriteToString());

        var fileGuid = pbxProject.AddFile("usr/lib/" + "libc++.dylib", "Frameworks/" + "libc++.dylib", PBXSourceTree.Sdk);
        pbxProject.AddFileToBuild(target, fileGuid);
        fileGuid = pbxProject.AddFile("usr/lib/" + "libz.dylib", "Frameworks/" + "libz.dylib", PBXSourceTree.Sdk);
        pbxProject.AddFileToBuild(target, fileGuid);
        fileGuid = pbxProject.AddFile("usr/lib/" + "libz.tbd", "Frameworks/" + "libz.tbd", PBXSourceTree.Sdk);
        pbxProject.AddFileToBuild(target, fileGuid);

        fileGuid = pbxProject.AddFile("usr/lib/" + "libbz2.dylib", "Frameworks/" + "libbz2.dylib", PBXSourceTree.Sdk);
        pbxProject.AddFileToBuild(target, fileGuid);
        fileGuid = pbxProject.AddFile("usr/lib/" + "libbz2.tbd", "Frameworks/" + "libbz2.tbd", PBXSourceTree.Sdk);
        pbxProject.AddFileToBuild(target, fileGuid);

        if ((settings.PlayersIPhone & PlayerOptionsIPhone.PlayerTypes.Native) == PlayerOptionsIPhone.PlayerTypes.Native)
        {
            pbxProject.AddFrameworkToProject(target, "CoreImage.framework", true);
        }

        File.WriteAllText(projPath, pbxProject.WriteToString());
#endif
    }
        static void AddGetSocialUrlScheme(string projectPath)
        {
            Debug.Log(string.Format("Setting up GetSocial deep linking for iOS <= 8 for '{0}'", projectPath));

            try
            {
                var plistInfoFile = new PlistDocument();

                string infoPlistPath = Path.Combine(projectPath, "Info.plist");
                plistInfoFile.ReadFromString(File.ReadAllText(infoPlistPath));

                AddGetSocialUrlSchemeToPlist(plistInfoFile);

                File.WriteAllText(infoPlistPath, plistInfoFile.WriteToString());
                Debug.Log(string.Format("Setting up GetSocial deep linking for iOS <= 8 was successful."));
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                Debug.LogError("Failed to set up GetSocial deep linking for iOS <= 8.");
            }
        }
示例#22
0
    public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            #if UNITY_IOS
            //Modify PList File and add AdMob ID
            string        plistPath = path + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));

            PlistElementDict rootDict = plist.root;

            string buildKey = "CFBundleVersion";
            rootDict.SetString(buildKey, "1");

            rootDict["GADApplicationIdentifier"] = new PlistElementString("ca-app-pub-8277769580123099~4622099382");

            PlistElementDict nsAppTransportSecurityDict = rootDict["NSAppTransportSecurity"].AsDict();
            nsAppTransportSecurityDict["NSAllowsArbitraryLoads"] = new PlistElementBoolean(true);

            rootDict["NSAppTransportSecurity"] = nsAppTransportSecurityDict;

            File.WriteAllText(plistPath, plist.WriteToString());


            //Add AdSupport.framework
            string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

            PBXProject proj = new PBXProject();
            proj.ReadFromString(File.ReadAllText(projPath));

            string target = proj.GetUnityMainTargetGuid();

            proj.AddFrameworkToProject(target, "AdSupport.framework", true);

            File.WriteAllText(projPath, proj.WriteToString());
            #endif
        }
    }
示例#23
0
        private static void UpdateProjectPlist(BuildTarget buildTarget, string plistPath)
        {
#if UNITY_IOS
            PlistDocument plist = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));

            PlistElementDict root = plist.root;

            PlistElementArray applicationQueriesSchemes = root.CreateArray("LSApplicationQueriesSchemes");
            applicationQueriesSchemes.AddString("fb");
            applicationQueriesSchemes.AddString("instagram");
            applicationQueriesSchemes.AddString("tumblr");
            applicationQueriesSchemes.AddString("twitter");

            root.SetString("NSCalendarsUsageDescription", "Some ad content may create a calendar event.");
            root.SetString("NSPhotoLibraryUsageDescription", "Some ad content may require access to the photo library.");
            root.SetString("NSCameraUsageDescription", "Some ad content may access camera to take picture.");
            root.SetString("NSMotionUsageDescription", "Some ad content may require access to accelerometer for interactive ad experience.");

            File.WriteAllText(plistPath, plist.WriteToString());
#endif
        }
    public static void ModifyXcodeProject(BuildTarget buildTarget, string pathToBuiltProject)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            var xcodeProjectPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
            var project          = new PBXProject();
            project.ReadFromFile(xcodeProjectPath);

            string target = project.TargetGuidByName("Unity-iPhone");
            project.AddCapability(target, PBXCapabilityType.BackgroundModes);
            project.WriteToFile(xcodeProjectPath);

            var infoPlistPath = pathToBuiltProject + "/Info.plist";
            var infoPlist     = new PlistDocument();
            infoPlist.ReadFromString(File.ReadAllText(infoPlistPath));
            PlistElementDict rootDictionary = infoPlist.root;
            rootDictionary.SetString("NSLocationWhenInUseUsageDescription", "For stuff leñe!");
            var backgroundModes = rootDictionary.CreateArray("UIBackgroundModes");
            backgroundModes.AddString("location");
            File.WriteAllText(infoPlistPath, infoPlist.WriteToString());
        }
    }
    public static void OnPostProcessBuild(BuildTarget target, string path)
    {
        Debug.LogWarning("BuildTargetxxxxxxxxxxxxxxxxxxxxxx");
        Debug.Log(path);
#if (UNITY_4 || UNITY_3 || UNITY_2)
        if (target == BuildTarget.iPhone)
#else
        if (target == BuildTarget.iOS)
#endif
        {
            // 创建 Xcode 工程配置的引用
            string     _projPath = PBXProject.GetPBXProjectPath(path);
            PBXProject _pbxProj  = new PBXProject();
            _pbxProj.ReadFromString(File.ReadAllText(_projPath));
            string targetGuid = _pbxProj.TargetGuidByName("Unity-iPhone");

            // 禁用 BitCode
            _pbxProj.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");

            // 添加 CoreTelephony.framework
            _pbxProj.AddFrameworkToProject(targetGuid, "CoreTelephony.framework", true);

            // 增加 Objc 编译选项,引入 category
            _pbxProj.AddBuildProperty(targetGuid, "OTHER_LDFLAGS", "-ObjC");

            // 保存 Xcode 工程配置
            _pbxProj.WriteToFile(_projPath);

            // 添加定位选项
            string        plistPath = path + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));
            PlistElementDict rootDict = plist.root;
            rootDict.SetString("NSLocationAlwaysUsageDescription", "使用定位服务");
            rootDict.SetString("NSLocationWhenInUseUsageDescription", "使用定位服务");
            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
        private static void UpdateIOSPlist(string path, Yodo1AdSettings settings)
        {
            string        plistPath = Path.Combine(path, "Info.plist");
            PlistDocument plist     = new PlistDocument();

            plist.ReadFromString(File.ReadAllText(plistPath));

            //Get Root
            PlistElementDict rootDict          = plist.root;
            PlistElementDict transportSecurity = rootDict.CreateDict("NSAppTransportSecurity");

            transportSecurity.SetBoolean("NSAllowsArbitraryLoads", true);

            //Set AppLovinSdkKey
            rootDict.SetString("AppLovinSdkKey", Yodo1EditorConstants.DEFAULT_APPLOVIN_SDK_KEY);

            //Set AdMob APP Id
            if (settings.iOSSettings.GlobalRegion)
            {
                rootDict.SetString("GADApplicationIdentifier", settings.iOSSettings.AdmobAppID);
            }

            PlistElementString privacy = (PlistElementString)rootDict["NSLocationAlwaysUsageDescription"];

            if (privacy == null)
            {
                rootDict.SetString("NSLocationAlwaysUsageDescription", "Some ad content may require access to the location for an interactive ad experience.");
            }

            PlistElementString privacy1 = (PlistElementString)rootDict["NSLocationWhenInUseUsageDescription"];

            if (privacy1 == null)
            {
                rootDict.SetString("NSLocationWhenInUseUsageDescription", "Some ad content may require access to the location for an interactive ad experience.");
            }

            File.WriteAllText(plistPath, plist.WriteToString());
        }
示例#27
0
    public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
    {
        if (target != BuildTarget.iOS)
        {
            return;
        }

        //------------------------------------------------------------------
        // Getting Objective C Code To Work with XCode
        //------------------------------------------------------------------
        string     projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
        PBXProject proj     = new PBXProject();

        proj.ReadFromString(File.ReadAllText(projPath));
        string targetGUID = proj.TargetGuidByName("Unity-iPhone");

        proj.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-ObjC");
        proj.SetBuildProperty(targetGUID, "ENABLE_BITCODE", "NO");
        File.WriteAllText(projPath, proj.WriteToString());
        //------------------------------------------------------------------
        // Getting Apple To Stop Bitching About Peripheral Usage Desciptions
        //------------------------------------------------------------------
        string        plistPath = pathToBuiltProject + "/Info.plist";
        PlistDocument plist     = new PlistDocument();

        plist.ReadFromString(File.ReadAllText(plistPath));

        // Create Values To Appease Apple...
        PlistElementDict rootDict = plist.root;

        rootDict.SetString("NSCalendarsUsageDescription", "Advertisement would like to create a calendar event.");
        rootDict.SetString("NSPhotoLibraryUsageDescription", "Advertisement would like to store a photo.");
        rootDict.SetString("NSBluetoothPeripheralUsageDescription", "Advertisement would like to use bluetooth.");
        rootDict.SetString("NSCameraUsageDescription", "App would like to use the Camera.");

        // Write to file
        File.WriteAllText(plistPath, plist.WriteToString());
    }
    public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        if (buildTarget == BuildTarget.iOS)
        {
                        #if UNITY_IPHONE
            // 修改xcode工程
            string     projPath = PBXProject.GetPBXProjectPath(path);
            PBXProject proj     = new PBXProject();
            proj.ReadFromString(File.ReadAllText(projPath));
            string target = proj.TargetGuidByName("Unity-iPhone");

            proj.AddFrameworkToProject(target, "libz.tbd", false);

            string fileName = Application.dataPath.Replace("Assets", "iOS/Umeng");
            XcodeModifyGeneral.CopyAndReplaceDirectory(fileName, Path.Combine(path, "Umeng"));
            List <string> filePaths = new List <string>();
            XcodeModifyGeneral.AddFilesToBuild(ref filePaths, path, "Umeng");
            foreach (var filepath in filePaths)
            {
                proj.AddFileToBuild(target, proj.AddFile(filepath, filepath));
            }

            proj.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)/Umeng");

            proj.WriteToFile(projPath);

            //获取info.plist
            string        plistPath = path + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));
            PlistElementDict rootDict = plist.root;

            rootDict.SetString("NSLocationWhenInUseUsageDescription", "MusicGame需要访问您的位置信息");

            plist.WriteToFile(plistPath);
                        #endif
        }
    }
示例#29
0
    public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            // Get plist
            var plistPath = pathToBuiltProject + "/Info.plist";
            var plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));

            // Get root
            var rootDict = plist.root;

            // Set file sharing enabled
            rootDict.SetBoolean("UIFileSharingEnabled", true);

            // Associate with .cytoidlevel file
            var array = rootDict.CreateArray("CFBundleDocumentTypes");
            var dict  = array.AddDict();
            dict.SetString("CFBundleTypeName", "Demoid Level Document");
            dict.SetString("LSHandlerRank", "Alternate");
            dict.SetString("CFBundleTypeRole", "Viewer");
            array = dict.CreateArray("LSItemContentTypes");
            array.AddString("io.demoid.demoidlevel");

            array = rootDict.CreateArray("UTExportedTypeDeclarations");
            dict  = array.AddDict();
            dict.SetString("UTTypeIdentifier", "io.demoid.demoidlevel");
            dict.SetString("UTTypeDescription", "Demoid Level Document");
            var dict2 = dict.CreateDict("UTTypeTagSpecification");
            dict2.SetString("public.filename-extension", "demoidlevel");
            dict2.SetString("public.mime-type", "application/demoid");
            array = dict.CreateArray("UTTypeConformsTo");
            array.AddString("public.data");

            // Write to file
            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
示例#30
0
    public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
    {
        if (target != BuildTarget.iOS)
        {
            return;
        }

        string        plistPath = pathToBuiltProject + "/Info.plist";
        PlistDocument plist     = new PlistDocument();

        plist.ReadFromString(File.ReadAllText(plistPath));

        // Skip App Store Connect export compliance questionnaire
        plist.root.SetBoolean("ITSAppUsesNonExemptEncryption", false);

        // Trace logging
        plist.root.SetBoolean("TeakLogTrace", true);

        // Add a non-Teak URL scheme
        AddURLSchemeToPlist(plist, "nonteak");

        File.WriteAllText(plistPath, plist.WriteToString());
    }