Esempio n. 1
0
    public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
    {
        if (target == BuildTarget.iOS)
        {
            string        plistPath = pathToBuiltProject + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));

            PlistElementDict rootDict = plist.root;
            rootDict.SetBoolean("AppsFlyerShouldSwizzle", appsFlyerShouldSwizzle);
            rootDict.SetBoolean("isDebug", isDebug);
            rootDict.SetString("devKey", devKey);
            rootDict.SetString("appID", appID);

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

            Debug.Log("Info.plist updated with AppsFlyerShouldSwizzle");
        }
        else if (target == BuildTarget.Android)
        {
            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }

            string path = dirPath + "/" + propFileName;
            string text =
                "AF_DEV_KEY=" + devKey + "\nAF_DEBUG=" + isDebug;
            StreamWriter writer = new StreamWriter(path, true);
            writer.WriteLine(text);
            writer.Close();
        }
    }
Esempio n. 2
0
    public static void ModfifyPlist(BuildTarget buildTarget, string path)
    {
        if (buildTarget != BuildTarget.iOS)
        {
            return;
        }

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

        plist.ReadFromFile(plistPath);

        PlistElementDict rootDict = plist.root;

        // example of changing a value:
        // rootDict.SetString("CFBundleVersion", "6.6.6");

        // example of adding a boolean key...
        // < key > ITSAppUsesNonExemptEncryption </ key > < false />
        // rootDict.SetBoolean("ITSAppUsesNonExemptEncryption", false);

        // Enable file sharing so that files can be pulled off of the device with iTunes
        rootDict.SetBoolean("UIFileSharingEnabled", true);
        // Enable this so that the files app can access the captured movies
        rootDict.SetBoolean("LSSupportsOpeningDocumentsInPlace", true);

        File.WriteAllText(plistPath, plist.WriteToString());
    }
    static void ProcessForiOS(string path)
    {
        // Manual copy for faster iteration
        string        plistPath = Path.Combine(path, "Info.plist");
        PlistDocument plist     = new PlistDocument();

        plist.ReadFromFile(plistPath);
        PlistElementDict root = plist.root;

        root.SetBoolean("UIFileSharingEnabled", true);
        root.SetBoolean("LSSupportsOpeningDocumentsInPlace", true);

        plist.WriteToFile(plistPath);
    }
    public static void EditXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            string WEBENGAGE_LICENSE_CODE = "YOUR-WEBENGAGE-LICENSE-CODE";
            string logLevel         = "VERBOSE";
            bool   apnsAutoRegister = true;
            bool   trackLocation    = false;

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

            rootDict.SetString("WEGLicenseCode", WEBENGAGE_LICENSE_CODE);
            rootDict.SetString("WEGLogLevel", logLevel);
            rootDict.SetBoolean("WEGApnsAutoRegister", apnsAutoRegister);

            if (trackLocation)
            {
                PlistElementArray bgModes = rootDict.CreateArray("UIBackgroundModes");
                bgModes.AddString("location");

                // TODO: Background location useage key (new in iOS 8)
                //rootDict.SetString("NSLocationAlwaysUsageDescription", "Uses background location");
            }

            // Write to Info.plist file
            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
Esempio n. 5
0
    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;

        // Set encryption usage boolean
        string encryptKey = "ITSAppUsesNonExemptEncryption";
        rootDict.SetBoolean(encryptKey, false);

        // 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
    }
Esempio n. 6
0
    static void EditorPlist(string path)
    {
        string        plistPath = path + "/Info.plist";
        PlistDocument plist     = new PlistDocument();

        plist.ReadFromString(File.ReadAllText(plistPath));
        PlistElementDict rootDict = plist.root;

        rootDict.SetString("NSPhotoLibraryUsageDescription", "保存截图到相册,需要访问你的相册");
        rootDict.SetString("NSContactsUsageDescription", "使用通讯录");
        rootDict.SetString("NSMicrophoneUsageDescription", "使用麦克风");
        rootDict.SetString("NSCameraUsageDescription", "使用相机");
        rootDict.SetString("NSLocationWhenInUseUsageDescription", "地理位置");
        rootDict.SetBoolean("UIFileSharingEnabled", DebugUtils.DebugMode);

        switch (channelName)
        {
        case "":
        {
            break;
        }
        }

        File.WriteAllText(plistPath, plist.WriteToString());
    }
Esempio n. 7
0
    public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

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

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

            proj.SetBuildProperty(target, "ENABLE_BITCODE", "false");

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



            // Add url schema to plist file
            string        plistPath = path + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));

            // Get root
            PlistElementDict rootDict = plist.root;
            rootDict.SetBoolean("UIRequiresFullScreen", true);
            plist.WriteToFile(plistPath);
        }
    }
Esempio n. 8
0
        public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
        {
            if (buildTarget == BuildTarget.iOS)
            {
                string        plistPath = pathToBuiltProject + "/Info.plist";
                PlistDocument plist     = new PlistDocument();
                plist.ReadFromString(File.ReadAllText(plistPath));

                PlistElementDict rootDict = plist.root;

                //Arbitrary loads
                PlistElementDict appTransportSec = rootDict.CreateDict("NSAppTransportSecurity");
                appTransportSec.SetBoolean("NSAllowsArbitraryLoads", true);

                //Camera
                rootDict.SetString("NSCameraUsageDescription", "Used for taking photos and videos.");

                //Microphone
                rootDict.SetString("NSMicrophoneUsageDescription", "Used for taking videos.");

                //Photo Library
                rootDict.SetString("NSPhotoLibraryUsageDescription", "Used for saving photos and videos.");
                rootDict.SetString("NSPhotoLibraryAddUsageDescription", "Used for adding photos / videos to the library.");

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

            // Encryption
            rootDict.SetBoolean("ITSAppUsesNonExemptEncryption", false);

            // File Sharing
            rootDict.SetString("NSCameraUsageDescription", "This app wants to save a photo to your device.");
            rootDict.SetString("NSPhotoLibraryUsageDescription", "This app wants to save a photo to your device.");
            rootDict.SetString("NSPhotoLibraryAddUsageDescription", "This app wants to save a photo to your device.");
            rootDict.SetString("NSLocationWhenInUseUsageDescription", "This app uses your location to make better recommendations.");

            // Push Notifications & Background
//            rootDict.SetBoolean("UIApplicationExitsOnSuspend", false);
            rootDict.values.Remove("UIApplicationExitsOnSuspend");
            rootDict.CreateArray("UIBackgroundModes").AddString("remote-notification");

            #if STENCIL_ADS
            rootDict.SetString("GADApplicationIdentifier", AdSettings.Instance.AppId.Ios);
            #endif

            // Write to file
            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
Esempio n. 10
0
    public static void OnPostprocessBuild(BuildTarget buildTarget, string pathToBuiltProject)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            // Handle xcodeproj
            string     projPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
            PBXProject proj     = new PBXProject();
            proj.ReadFromString(File.ReadAllText(projPath));
            string target = proj.TargetGuidByName(PBXProject.GetUnityTargetName());

            proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");

            proj.AddFrameworkToProject(target, "libxml2.tbd", false);
            proj.AddFrameworkToProject(target, "libz.tbd", false);
            proj.AddFrameworkToProject(target, "ReplayKit.framework", false);
            proj.AddFrameworkToProject(target, "CoreTelephony.framework", false);

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

            // Handle plist
            string        plistPath = pathToBuiltProject + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));
            PlistElementDict rootDict = plist.root;
            rootDict.SetBoolean("UIFileSharingEnabled", true);
            rootDict.SetString("NSPhotoLibraryAddUsageDescription", "是否允许此App访问您的相册?");

            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
Esempio n. 11
0
        private static void OnPostprocessBuild(BuildTarget target, string pathToBuildProject)
        {
            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
            string     _projPath = PBXProject.GetPBXProjectPath(pathToBuildProject);
            PBXProject project   = new PBXProject();

            project.ReadFromString(File.ReadAllText(_projPath));
            string targetGuid = project.TargetGuidByName("Unity-iPhone");

            //project.AddFrameworkToProject(targetGuid, "Security.framework", false);

            project.WriteToFile(_projPath);


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

            plist.ReadFromString(File.ReadAllText(plistPath));
            PlistElementDict rootDict = plist.root;

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

            dictTmp.SetBoolean("NSAllowsArbitraryLoads", true);

            // 保存plist
            plist.WriteToFile(plistPath);
        }
Esempio n. 12
0
    /// <summary>
    /// 设置私有数据
    /// </summary>
    /// <param name="plist"></param>
    /// <param name="privacySensiticeDataList"></param>
    private static void SetPrivacySensiticeData(PlistDocument plist, List <XcodeProjectSetting.PrivacySensiticeData> privacySensiticeDataList)
    {
        PlistElementDict rootDict = plist.root;
        int count = privacySensiticeDataList.Count;

        for (int i = 0; i < count; i++)
        {
            XcodeProjectSetting.PrivacySensiticeData data = privacySensiticeDataList[i];
            switch (data.type)
            {
            case XcodeProjectSetting.NValueType.String:
                rootDict.SetString(data.key, data.value);
                break;

            case XcodeProjectSetting.NValueType.Int:
                rootDict.SetInteger(data.key, int.Parse(data.value));
                break;

            case XcodeProjectSetting.NValueType.Bool:
                rootDict.SetBoolean(data.key, bool.Parse(data.value));
                break;

            default:
                rootDict.SetString(data.key, data.value);
                break;
            }
        }
    }
Esempio n. 13
0
    public void OnPostprocessBuild(BuildTarget target, 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;

        // Set encryption usage boolean
        string encryptKey = "ITSAppUsesNonExemptEncryption";
        rootDict.SetBoolean(encryptKey, false);

        // 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

        // あんま意味ないけど

        if (PlayerSettings.applicationIdentifier.Contains("development"))
        {
            PlayerSettings.productName = PlayerSettings.productName.Replace("Dev", "");
            PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, PlayerSettings.applicationIdentifier.Replace(".development", ""));
        }
    }
Esempio n. 14
0
    public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            string     projPath = PBXProject.GetPBXProjectPath(path);
            PBXProject proj     = new PBXProject();
            proj.ReadFromString(File.ReadAllText(projPath));
            string target = proj.TargetGuidByName("Unity-iPhone");

            proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
            proj.SetBuildProperty(target, "DEVELOPMENT_TEAM", "JLT4P23V2G");

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

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

            //rootDict.SetString ("CFBundleVersion", GetVer ());//GetVer() 返回自定义自增值
            rootDict.SetBoolean("UIFileSharingEnabled", true);

            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
Esempio n. 15
0
    public static void OnPostprocessBuild(BuildTarget BuildTarget, string path)
    {
        if (BuildTarget == BuildTarget.iOS)
        {
            string     projPath = PBXProject.GetPBXProjectPath(path);
            PBXProject proj     = new PBXProject();
            proj.ReadFromString(File.ReadAllText(projPath));

            //add Other link flag
            string target = proj.TargetGuidByName(PBXProject.GetUnityTargetName());
            proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
            File.WriteAllText(projPath, proj.WriteToString());

            //add framework
            proj.AddFrameworkToProject(target, "AdSupport.framework", false);
            proj.AddFrameworkToProject(target, "StoreKit.framework", false);
            proj.AddFrameworkToProject(target, "AVFoundation.framework", false);
            proj.AddFrameworkToProject(target, "SystemConfiguration.framework", false);
            proj.AddFrameworkToProject(target, "JavaScriptCore.framework", false);
            proj.AddFrameworkToProject(target, "ImageIO.framework", false);
            proj.AddFrameworkToProject(target, "UIKit.framework", false);
            proj.AddFrameworkToProject(target, "libz.1.tbd", false);
            File.WriteAllText(projPath, proj.WriteToString());

            //add ATS in plist
            string        plistPath = path + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));
            PlistElementDict dictTransportSecurity = plist.root ["NSAppTransportSecurity"].AsDict();
            dictTransportSecurity.SetBoolean("NSAllowsArbitraryLoads", true);
            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
    static void SetPlist(string pathToBuildProject)
    {
        string _plistPath = pathToBuildProject + "/Info.plist";

        Logger.Log("plist path:" + _plistPath);

        PlistDocument _plist = new PlistDocument();

        _plist.ReadFromString(File.ReadAllText(_plistPath));
        PlistElementDict _rootDic = _plist.root;

        // Add value of NSAppTransportSecurity in Xcode plist
        var atsKey = "NSAppTransportSecurity";
        PlistElementDict dictTmp = _rootDic.CreateDict(atsKey);

        dictTmp.SetBoolean("NSAllowsArbitraryLoads", true);


        // Calendar
        _rootDic.SetString("NSCalendarsUsageDescription", "App shall access calendar with your permission");
        //< !--Photos-- >
        _rootDic.SetString("NSPhotoLibraryUsageDescription", "App shall access photos with your permission");


        File.WriteAllText(_plistPath, _plist.WriteToString());
    }
Esempio n. 17
0
 private static void AddConfig(PlistElementDict dic, Dictionary <string, object> values)
 {
     foreach (var pair in values)
     {
         if (pair.Value is string)
         {
             dic.SetString(pair.Key, (string)pair.Value);
         }
         else if (pair.Value is int)
         {
             dic.SetInteger(pair.Key, (int)pair.Value);
         }
         else if (pair.Value is bool)
         {
             dic.SetBoolean(pair.Key, (bool)pair.Value);
         }
         else if (pair.Value is Dictionary <string, object> )
         {
             var parent = dic.CreateDict(pair.Key);
             AddConfig(parent, (Dictionary <string, object>)pair.Value);
         }
         else if (pair.Value is List <object> )
         {
             var parent = dic.CreateArray(pair.Key);
             AddConfig(parent, (List <object>)pair.Value);
         }
     }
 }
Esempio n. 18
0
        public static void OnPostprocessBuild(BuildTarget target, string buildPath)
        {
            if (!ENABLED)
            {
                return;
            }

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

                PBXProject pbxProject = new PBXProject();
                pbxProject.ReadFromFile(pbxProjectPath);

#if UNITY_2019_3_OR_NEWER
                string targetGUID = pbxProject.GetUnityFrameworkTargetGuid();
#else
                string targetGUID = pbxProject.TargetGuidByName(PBXProject.GetUnityTargetName());
#endif

                // Minimum supported iOS version on Unity 2018.1 and later is 8.0
#if !UNITY_2018_1_OR_NEWER
                if (MINIMUM_TARGET_8_OR_ABOVE)
                {
#endif
                pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-weak_framework PhotosUI");
                pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-framework Photos");
                pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-framework MobileCoreServices");
                pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-framework ImageIO");
#if !UNITY_2018_1_OR_NEWER
            }
            else
            {
                pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-weak_framework Photos");
                pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-weak_framework PhotosUI");
                pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-framework AssetsLibrary");
                pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-framework MobileCoreServices");
                pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-framework ImageIO");
            }
#endif

                pbxProject.RemoveFrameworkFromProject(targetGUID, "Photos.framework");

                File.WriteAllText(pbxProjectPath, pbxProject.WriteToString());

                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_ADDITIONS_USAGE_DESCRIPTION);
                if (DONT_ASK_LIMITED_PHOTOS_PERMISSION_AUTOMATICALLY_ON_IOS14)
                {
                    rootDict.SetBoolean("PHPhotoLibraryPreventAutomaticLimitedAccessAlert", true);
                }

                File.WriteAllText(plistPath, plist.WriteToString());
            }
        }
Esempio n. 19
0
        public static void OnPostProcessBuild(BuildTarget target, string path)
        {
            if (target == BuildTarget.StandaloneOSXIntel)
            {
                Debug.LogError("AVPro Video doesn't support target StandaloneOSXIntel, please use StandaloneOSXIntel64 or remove this PostProcessBuild script");

                EditorUtility.DisplayDialog("AVPro Video", "AVPro Video doesn't support target StandaloneOSXIntel, please use StandaloneOSXIntel64 or remove this PostProcessBuild script", "Ok");
            }

#if AVPROVIDEO_UNITY_SUPPORTS_PLISTEDIT
            // On Apple platforms we need to adjust the plist to allow loading from HTTP for video streaming
            if ((target == BuildTarget.StandaloneOSXIntel) ||
                (target == BuildTarget.StandaloneOSXIntel64) ||
                (target == BuildTarget.StandaloneOSXUniversal))
            {
                string        plistPath = path + "/Contents/Info.plist";
                PlistDocument plist     = new PlistDocument();
                plist.ReadFromString(File.ReadAllText(plistPath));

                // Get root
                PlistElementDict rootDict = plist.root;

                PlistElementDict nsAppTransportSecurity = rootDict.CreateDict("NSAppTransportSecurity");
                nsAppTransportSecurity.SetBoolean("NSAllowsArbitraryLoads", true);

                File.WriteAllText(plistPath, plist.WriteToString());
            }
#endif
        }
    public static void ChangeXCodePlist(BuildTarget target, string pathToBuiltProject)
    {
        if (target == BuildTarget.iOS)
        {
            //
            string        plistPath = Path.Combine(pathToBuiltProject, "Info.plist");
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromFile(plistPath);

            PlistElementDict rootDict = plist.root;

            rootDict.SetBoolean("UIFileSharingEnabled", true);
            rootDict.SetBoolean("LSSupportsOpeningDocumentsInPlace", true);

            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
Esempio n. 21
0
        public static void OnPostprocessBuild(BuildTarget target, string buildPath)
        {
            if (!Settings.Instance.AutomatedSetup)
            {
                return;
            }

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

                PBXProject pbxProject = new PBXProject();
                pbxProject.ReadFromFile(pbxProjectPath);

#if UNITY_2019_3_OR_NEWER
                string targetGUID = pbxProject.GetUnityFrameworkTargetGuid();
#else
                string targetGUID = pbxProject.TargetGuidByName(PBXProject.GetUnityTargetName());
#endif

                // Minimum supported iOS version on Unity 2018.1 and later is 8.0
#if !UNITY_2018_1_OR_NEWER
                if (!Settings.Instance.MinimumiOSTarget8OrAbove)
                {
                    pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-weak_framework Photos");
                    pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-weak_framework PhotosUI");
                    pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-framework AssetsLibrary");
                    pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-framework MobileCoreServices");
                    pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-framework ImageIO");
                }
                else
#endif
                {
                    pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-weak_framework PhotosUI");
                    pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-framework Photos");
                    pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-framework MobileCoreServices");
                    pbxProject.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-framework ImageIO");
                }

                pbxProject.RemoveFrameworkFromProject(targetGUID, "Photos.framework");

                File.WriteAllText(pbxProjectPath, pbxProject.WriteToString());

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

                PlistElementDict rootDict = plist.root;
                rootDict.SetString("NSPhotoLibraryUsageDescription", Settings.Instance.PhotoLibraryUsageDescription);
                rootDict.SetString("NSPhotoLibraryAddUsageDescription", Settings.Instance.PhotoLibraryAdditionsUsageDescription);
                if (Settings.Instance.DontAskLimitedPhotosPermissionAutomaticallyOnIos14)
                {
                    rootDict.SetBoolean("PHPhotoLibraryPreventAutomaticLimitedAccessAlert", true);
                }

                File.WriteAllText(plistPath, plist.WriteToString());
            }
        }
Esempio n. 22
0
    public static void ApplyDataBinding(string pbxmod, string rootpath, PBXProject proj, string target)
    {
        DataBinding dataBinding = new DataBinding(pbxmod);

        ApplyData(dataBinding.libs, (valueOne, valueTwo) => {
            proj.AddFileToBuild(target, proj.AddFile("usr/lib/" + valueOne, "Frameworks/" + valueOne, PBXSourceTree.Sdk));
        });
        ApplyData(dataBinding.frameworks, (valueOne, valueTwo) => {
            proj.AddFrameworkToProject(target, valueOne, false);
        });
        ApplyData(dataBinding.plist, (valueOne, valueTwo) => {
            //修改plist

            string plistPath    = rootpath + "/Info.plist";
            PlistDocument plist = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));
            PlistElementDict rootDict = plist.root;
            if (valueTwo == "True" || valueTwo == "False")
            {
                rootDict.SetBoolean(valueOne, bool.Parse(valueTwo));
                plist.WriteToFile(plistPath);
                return;
            }
            if (ChargeIsNumber(valueTwo))
            {
                rootDict.SetInteger(valueOne, int.Parse(valueTwo));
                plist.WriteToFile(plistPath);
                return;
            }
            // 语音听写需要开启的权限
            rootDict.SetString(valueOne, valueTwo);
            //保存plist
            plist.WriteToFile(plistPath);
        });
        Debug.Log("修改PLIST成功!");
        ApplyData(dataBinding.bitcode, (valueOne, ValueTwo) => {
            proj.SetBuildProperty(target, "ENABLE_BITCODE", valueOne);
        });
        Debug.Log("修改ENABLE_BITCODE成功!");
        ApplyData(dataBinding.code_sign_identity, (valueOne, ValueTwo) => {
            proj.SetBuildProperty(target, "CODE_SIGN_IDENTITY", valueOne + ":" + ValueTwo);
        });
        Debug.Log("修改CODE_SIGN_IDENTITY成功!");
        ApplyData(dataBinding.provisioning_profile_specifier, (valueOne, ValueTwo) => {
            proj.SetBuildProperty(target, "PROVISIONING_PROFILE_SPECIFIER", valueOne);
        });
        Debug.Log("修改PROVISIONING_PROFILE_SPECIFIER成功!");
        ApplyData(dataBinding.framework_search_paths, (valueOne, ValueTwo) => {
            proj.SetBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", valueOne);
        });
        Debug.Log("修改FRAMEWORK_SEARCH_PATHS成功!");
        //设置框架路径时,无法实现在Xcode中依次添加各个路径,添加一个可以,添加第二个覆盖第一个
        ApplyData(dataBinding.other_ldflags, (valueOne, ValueTwo) => {
            proj.SetBuildProperty(target, "OTHER_LDFLAGS", valueOne);
        });
        Debug.Log("修改OTHER_LDFLAGS成功!");
    }
    static void UpdateInfoPlist(string path)
    {
        // Add url schema to plist file
        string        plistPath = path + "/Info.plist";
        PlistDocument plist     = new PlistDocument();

        plist.ReadFromString(File.ReadAllText(plistPath));
        // Get root
        PlistElementDict rootDict = plist.root;

        rootDict.SetBoolean("UIRequiresFullScreen", true);
        rootDict.SetString("NSCameraUsageDescription", "not used");
        rootDict.SetString("NSCalendarsUsageDescription", "Some ad content may access calendar");
        rootDict.SetString("NSPhotoLibraryUsageDescription", "Some ad content may access photo library");
        rootDict.SetBoolean("ITSAppUsesNonExemptEncryption", false);

        plist.WriteToFile(plistPath);
    }
    /// <summary>
    /// 設定UIRequiresFullScreen
    /// </summary>
    protected void SetRequireFullScreen()
    {
        Debug.Log("Start SetRequireFullScreen");
        PlistDocument    aPDoc     = GetProjectPlist();
        PlistElementDict aRootDict = aPDoc.root;

        aRootDict.SetBoolean("UIRequiresFullScreen", true);

        File.WriteAllText(mInfoPlistFullPath, aPDoc.WriteToString());
    }
        static void ModifyPlist(string path)
        {
            // Info.plist
            string        plistPath = path + "/Info.plist";
            PlistDocument plist     = new PlistDocument();

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

            // ROOT
            PlistElementDict  rootDict = plist.root;
            PlistElementArray urlTypes = rootDict.CreateArray("CFBundleURLTypes");

            // Add URLScheme For Wechat
            PlistElementDict wxUrl = urlTypes.AddDict();

            wxUrl.SetString("CFBundleTypeRole", "Editor");
            wxUrl.SetString("CFBundleURLName", "weixin");
            wxUrl.SetString("CFBundleURLSchemes", val: Config.wechatAppId);
            PlistElementArray wxUrlScheme = wxUrl.CreateArray("CFBundleURLSchemes");

            wxUrlScheme.AddString(val: Config.wechatAppId);

            // Add URLScheme For jiguang
            PlistElementDict jgUrl = urlTypes.AddDict();

            jgUrl.SetString("CFBundleTypeRole", "Editor");
            jgUrl.SetString("CFBundleURLName", "jiguang");
            jgUrl.SetString("CFBundleURLSchemes", val: "jiguang-" + Config.jgAppKey);
            PlistElementArray jgUrlScheme = jgUrl.CreateArray("CFBundleURLSchemes");

            jgUrlScheme.AddString(val: "jiguang-" + Config.jgAppKey);

            // 白名单 for wechat
            PlistElementArray queriesSchemes = rootDict.CreateArray("LSApplicationQueriesSchemes");

            queriesSchemes.AddString("wechat");
            queriesSchemes.AddString("weixin");
            queriesSchemes.AddString(val: Config.wechatAppId);

            // HTTP 设置
            const string     atsKey  = "NSAppTransportSecurity";
            PlistElementDict dictTmp = rootDict.CreateDict(key: atsKey);

            dictTmp.SetBoolean("NSAllowsArbitraryLoads", true);

            PlistElementArray backModes = rootDict.CreateArray("UIBackgroundModes");

            backModes.AddString("remote-notification");

            // 出口合规信息
            rootDict.SetBoolean("ITSAppUsesNonExemptEncryption", false);

            // 写入
            File.WriteAllText(path: plistPath, plist.WriteToString());
        }
Esempio n. 26
0
        void SetNoneSDKProjectSetting()
        {
            string path = GetXcodeProjectPath(option.PlayerOption.locationPathName);

            #region 添加XCode引用的Framework

            string     projPath = PBXProject.GetPBXProjectPath(path);
            PBXProject proj     = new PBXProject();
            proj.ReadFromString(File.ReadAllText(projPath));
            string target = proj.TargetGuidByName("Unity-iPhone");

            // 系统框架
            // Bugly依赖
            proj.AddFrameworkToProject(target, "libz.tbd", false);
            proj.AddFrameworkToProject(target, "libc++.tbd", false);

            #endregion 添加XCode引用的Framework

            // BuildSetting修改
            proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
            proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");

            #region 修改Xcode工程Info.plist

            string        plistPath = Path.Combine(path, "Info.plist");
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromFile(plistPath);
            PlistElementDict rootDict = plist.root;
            // 调整默认配置
            rootDict.SetString("CFBundleDevelopmentRegion", "zh_TW");
            // 权限配置
            rootDict.SetString("NSCameraUsageDescription", "是否允许访问相机?");
            rootDict.SetString("NSMicrophoneUsageDescription", "是否允许使用麦克风?");
            rootDict.SetString("NSPhotoLibraryAddUsageDescription", "是否允许添加照片?");
            rootDict.SetString("NSMicrophoneUsageDescription", "是否允许访问相册?");
            rootDict.SetString("NSLocationUsageDescription", "App需要您的同意,才能访问位置");
            rootDict.SetString("NSLocationWhenInUseUsageDescription", "App需要您的同意,才能在使用期间访问位置");
            rootDict.SetString("NSLocationAlwaysUsageDescription", "App需要您的同意,才能始终访问位置");

            // Set encryption usage boolean
            string encryptKey = "ITSAppUsesNonExemptEncryption";
            rootDict.SetBoolean(encryptKey, false);
            // remove exit on suspend if it exists.ios13新增
            string exitsOnSuspendKey = "UIApplicationExitsOnSuspend";
            if (rootDict.values.ContainsKey(exitsOnSuspendKey))
            {
                rootDict.values.Remove(exitsOnSuspendKey);
            }
            plist.WriteToFile(plistPath);

            #endregion 修改Xcode工程Info.plist

            File.WriteAllText(projPath, proj.WriteToString());
        }
Esempio n. 27
0
        /// <summary>
        /// ATS
        /// </summary>
        public static void SetATS(string buildPath, bool enableATS)
        {
            PlistDocument plist = GetInfoPlist(buildPath);

            //ATS
            PlistElementDict atsDict = plist.root.CreateDict(XcodeProjectConst.ATS_KEY);

            atsDict.SetBoolean(XcodeProjectConst.ALLOWS_ARBITRARY_LOADS_KEY, enableATS);

            plist.WriteToFile(GetInfoPlistPath(buildPath));
        }
Esempio n. 28
0
    public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
    {
        if (buildTarget != BuildTarget.iOS)
        {
            return;
        }

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

        plist.ReadFromFile(plistPath);
        PlistElementDict rootDict = plist.root;

        // Change values
        rootDict.SetBoolean("UIFileSharingEnabled", true);              // https://developer.apple.com/documentation/bundleresources/information_property_list/uifilesharingenabled
        rootDict.SetBoolean("LSSupportsOpeningDocumentsInPlace", true); // https://developer.apple.com/documentation/bundleresources/information_property_list/lssupportsopeningdocumentsinplace

        plist.WriteToFile(plistPath);                                   // Write plist
    }
Esempio n. 29
0
    public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            Debug.Log("iOS post build");
            string        plistPath = pathToBuiltProject + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromFile(plistPath);

            PlistElementDict rootDict = plist.root;

            rootDict.SetBoolean("UIFileSharingEnabled", true);
            rootDict.SetBoolean("LSSupportsOpeningDocumentsInPlace", true);

            var capabilities = rootDict["UIRequiredDeviceCapabilities"].AsArray();
            capabilities.AddString("wifi");

            plist.WriteToFile(plistPath);
        }
    }
Esempio n. 30
0
 private static void UpdatePlist(string buildPath)
 {
             #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7
     string        plistPath = Path.Combine(buildPath, "Info.plist");
     PlistDocument plist     = new PlistDocument();
     plist.ReadFromString(File.ReadAllText(plistPath));
     PlistElementDict dict = plist.root.CreateDict("NSAppTransportSecurity");
     dict.SetBoolean("NSAllowsArbitraryLoads", true);
     File.WriteAllText(plistPath, plist.WriteToString());
             #endif
 }