Ejemplo n.º 1
0
    private static void AddElementInfoPlist(string pathToBuiltProject)
    {
#if UNITY_IOS
        // Get plist
        string plistPath = pathToBuiltProject + "/Info.plist";
        var    plist     = new UnityEditor.iOS.Xcode.PlistDocument();
        plist.ReadFromString(File.ReadAllText(plistPath));
        bool changed = false;

        // Get root
        UnityEditor.iOS.Xcode.PlistElementDict rootDict = plist.root;

        foreach (var p in InfoPlist)
        {
            if (!rootDict.values.ContainsKey(p.Key))
            {
                rootDict.CreateDict(p.Key);
            }
            rootDict.SetString(p.Key, p.Value);
            changed = true;
        }

        if (changed)
        {
            // Write to file
            File.WriteAllText(plistPath, plist.WriteToString());
        }
#endif
    }
        static void AddLanguage(string path, params string[] languages)
        {
            var plistPath = Path.Combine (path, "Info.plist");
            var plist = new PlistDocument ();

            plist.ReadFromFile (plistPath);

            var localizationKey = "CFBundleLocalizations";

            var localizations = plist.root.values
            .Where (kv => kv.Key == localizationKey)
            .Select (kv => kv.Value)
            .Cast<PlistElementArray> ()
            .FirstOrDefault ();

            if (localizations == null)
                localizations = plist.root.CreateArray (localizationKey);

            foreach (var language in languages) {
                if (localizations.values.Select (el => el.AsString ()).Contains (language) == false)
                    localizations.AddString (language);
            }

            plist.WriteToFile (plistPath);
        }
Ejemplo n.º 3
0
        private static void ModifyPlist(string plistPath)
        {
            // Create PlistDocument
              PlistDocument plist = new PlistDocument();
              plist.ReadFromString(File.ReadAllText(plistPath));
              PlistElementDict rootDict = plist.root;

              // Clear existing Appboy Unity dictionary
              if (rootDict["Appboy"] != null) {
            rootDict["Appboy"]["Unity"] = null;
              }

              // Add Appboy Unity keys to Plist
              if (AppboyConfig.IOSAutomatesIntegration) {
            // The Appboy Unity dictionary
            PlistElementDict appboyUnityDict = (rootDict["Appboy"] == null) ? rootDict.CreateDict("Appboy").CreateDict("Unity") : rootDict["Appboy"].AsDict().CreateDict("Unity");

            // Add iOS automated integration build keys to Plist
            if (ValidateField(ABKUnityApiKey, AppboyConfig.ApiKey, "Appboy will not be initialized.")) {
              appboyUnityDict.SetString(ABKUnityApiKey, AppboyConfig.ApiKey.Trim());
            }
            appboyUnityDict.SetBoolean(ABKUnityAutomaticPushIntegrationKey, AppboyConfig.IOSIntegratesPush);
            appboyUnityDict.SetBoolean(ABKUnityDisableAutomaticPushRegistrationKey, AppboyConfig.IOSDisableAutomaticPushRegistration);
            if (AppboyConfig.IOSPushIsBackgroundEnabled) {
              PlistElementArray backgroundModes = (rootDict["UIBackgroundModes"] == null) ? rootDict.CreateArray("UIBackgroundModes") : rootDict["UIBackgroundModes"].AsArray();
              backgroundModes.AddString("remote-notification");
            }

            // Set push listeners
            if (ValidateListenerFields(ABKUnityPushReceivedGameObjectKey, AppboyConfig.IOSPushReceivedGameObjectName,
              ABKUnityPushReceivedCallbackKey, AppboyConfig.IOSPushReceivedCallbackMethodName)) {
              appboyUnityDict.SetString(ABKUnityPushReceivedGameObjectKey, AppboyConfig.IOSPushReceivedGameObjectName.Trim());
              appboyUnityDict.SetString(ABKUnityPushReceivedCallbackKey, AppboyConfig.IOSPushReceivedCallbackMethodName.Trim());
            }

            if (ValidateListenerFields(ABKUnityPushOpenedGameObjectKey, AppboyConfig.IOSPushOpenedGameObjectName,
              ABKUnityPushOpenedCallbackKey, AppboyConfig.IOSPushOpenedCallbackMethodName)) {
              appboyUnityDict.SetString(ABKUnityPushOpenedGameObjectKey, AppboyConfig.IOSPushOpenedGameObjectName.Trim());
              appboyUnityDict.SetString(ABKUnityPushOpenedCallbackKey, AppboyConfig.IOSPushOpenedCallbackMethodName.Trim());
            }

            // Set in-app message listener
            if (ValidateListenerFields(ABKUnityInAppMessageGameObjectKey, AppboyConfig.IOSInAppMessageGameObjectName,
              ABKUnityInAppMessageCallbackKey, AppboyConfig.IOSInAppMessageCallbackMethodName)) {
              appboyUnityDict.SetString(ABKUnityInAppMessageGameObjectKey, AppboyConfig.IOSInAppMessageGameObjectName.Trim());
              appboyUnityDict.SetString(ABKUnityInAppMessageCallbackKey, AppboyConfig.IOSInAppMessageCallbackMethodName.Trim());
              appboyUnityDict.SetBoolean(ABKUnityHandleInAppMessageDisplayKey, AppboyConfig.IOSDisplayInAppMessages);
            }

            // Set feed listener
            if (ValidateListenerFields(ABKUnityFeedGameObjectKey, AppboyConfig.IOSFeedGameObjectName,
              ABKUnityFeedCallbackKey, AppboyConfig.IOSFeedCallbackMethodName)) {
              appboyUnityDict.SetString(ABKUnityFeedGameObjectKey, AppboyConfig.IOSFeedGameObjectName.Trim());
              appboyUnityDict.SetString(ABKUnityFeedCallbackKey, AppboyConfig.IOSFeedCallbackMethodName.Trim());
            }
              }

              // Write changes to XCode project and Info.plist
              File.WriteAllText(plistPath, plist.WriteToString());
        }
Ejemplo n.º 4
0
    public static void OnPostprocessBuild(string xcodePath, string configPath)
    {
        pluginPath = configPath.Replace("XcodeSetting.json", "");
        string     projPath = PBXProject.GetPBXProjectPath(xcodePath);
        PBXProject proj     = new PBXProject();

        proj.ReadFromString(File.ReadAllText(projPath));

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

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

        //string target = proj.TargetGuidByName(PBXProject.GetUnityTargetName());
        //string target = proj.TargetGuidByName("UnityFramework");
        //string productName = proj.GetBuildPropertyForAnyConfig(target, "PRODUCT_NAME");
        string entitlementFilePath          = Path.Combine(PBXProject.GetUnityTargetName(), "usdk.entitlements");
        ProjectCapabilityManager pcbManager = new ProjectCapabilityManager(proj, projPath, entitlementFilePath, PBXProject.GetUnityTargetName());

        //读取配置文件
        string    json  = File.ReadAllText(configPath);
        Hashtable table = json.hashtableFromJson();

        embedFrameworksTable = table.SGet <Hashtable>("embedframeworks");

        //plist
        SetPlist(proj, rootDict, table.SGet <Hashtable>("plist"));
        plist.WriteToFile(plistPath);

        //lib
        SetLibs(proj, table.SGet <Hashtable>("libs"));
        //framework
        SetFrameworks(proj, table.SGet <Hashtable>("frameworks"));
        //building setting
        SetBuildProperties(proj, table.SGet <Hashtable>("properties"));
        SetShellScriptBuildPhase(proj, table.SGet <Hashtable>("shellscript"));
        //复制文件
        CopyFiles(proj, xcodePath, table.SGet <Hashtable>("files"));
        //复制文件夹
        CopyFolders(proj, xcodePath, table.SGet <Hashtable>("folders"));
        //文件编译符号
        SetFilesCompileFlag(proj, table.SGet <Hashtable>("filesCompileFlag"));
        //加入能力
        SetCapabilitys(pcbManager, table.SGet <Hashtable>("capabilitys"));
        //写入
        File.WriteAllText(projPath, proj.WriteToString());

        Console.WriteLine("***Info.plist*****\n" + File.ReadAllText(plistPath));
    }
    [PostProcessBuildAttribute(0)] // Configures this this post process to run first
    public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
    {
#if UNITY_IOS
        var infoPlist     = new UnityEditor.iOS.Xcode.PlistDocument();
        var infoPlistPath = pathToBuiltProject + "/Info.plist";
        infoPlist.ReadFromFile(infoPlistPath);

        // Register ios URL scheme for external apps to launch this app.
        var urlTypeDict = infoPlist.root.CreateArray("CFBundleURLTypes").AddDict();
        urlTypeDict.SetString("CFBundleURLName", "org.identitymodel.unityclient");
        var urlSchemes = urlTypeDict.CreateArray("CFBundleURLSchemes");
        urlSchemes.AddString("io.identitymodel.native");

        infoPlist.WriteToFile(infoPlistPath);
#endif
    }
Ejemplo n.º 6
0
    public static void PostProcessZhakaas(BuildTarget buildTarget, string path)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            string plistPath = path + "/Info.plist";
            var    plist     = new UnityEditor.iOS.Xcode.PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));

            // Get root
            var rootDict = plist.root;

            var buildKey2 = "ITSAppUsesNonExemptEncryption";
            rootDict.SetString(buildKey2, "false");

            string exitsOnSuspendKey = "UIApplicationExitsOnSuspend";
            if (rootDict.values.ContainsKey(exitsOnSuspendKey))
            {
                rootDict.values.Remove(exitsOnSuspendKey);
            }

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

            //////////////////////////////
            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");
            proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");

            proj.AddFrameworkToProject(target, "AdSupport.framework", false);
            proj.AddFrameworkToProject(target, "iAd.framework", false);
            proj.AddFrameworkToProject(target, "CoreData.framework", false);
            proj.AddFrameworkToProject(target, "StoreKit.framework", false);

            File.WriteAllText(projPath, proj.WriteToString());
        }
    }
        static void AddPermissions(string path , params KeyValuePair<string,string>[] permissions)
        {
            var plistPath = Path.Combine (path, "Info.plist");
            var plist = new PlistDocument ();

            plist.ReadFromFile (plistPath);
            foreach(var permission in permissions){

                var count = plist.root.values
                    .Where (kv => kv.Key == permission.Key)
                    .Select (kv => kv.Value)
                    .Count();

                if(count == 0){
                    plist.root.SetString(permission.Key,permission.Value);
                }
            }

            plist.WriteToFile (plistPath);
        }
Ejemplo n.º 8
0
    static void _AddDeviceCapabilities(string path)
    {
        string pbxprojPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
        
        PBXProject project = new PBXProject();
        project.ReadFromString(File.ReadAllText(pbxprojPath));
        string target = project.TargetGuidByName("Unity-iPhone");

        project.AddFrameworkToProject(target, "AdSupport.framework", false);
        project.AddFrameworkToProject(target, "AudioToolbox.framework", false);
        project.AddFrameworkToProject(target, "AVFoundation.framework", false);
        project.AddFrameworkToProject(target, "CoreGraphics.framework", false);
        project.AddFrameworkToProject(target, "CoreTelephony.framework", false);
        project.AddFrameworkToProject(target, "EventKit.framework", false);
        project.AddFrameworkToProject(target, "EventKitUI.framework", false);
        project.AddFrameworkToProject(target, "MessageUI.framework", false);
        project.AddFrameworkToProject(target, "StoreKit.framework", false);
        project.AddFrameworkToProject(target, "SystemConfiguration.framework", false);

        project.SetBuildProperty(target, "CLANG_ENABLE_MODULES", "YES");

        File.WriteAllText(pbxprojPath, project.WriteToString());

        string infoPlistPath = Path.Combine(path, "./Info.plist");
        PlistDocument plist = new PlistDocument();
        plist.ReadFromString(File.ReadAllText(infoPlistPath));

        PlistElementDict rootDict = plist.root;
        PlistElementArray deviceCapabilityArray = rootDict.CreateArray("UIRequiredDeviceCapabilities");
        deviceCapabilityArray.AddString("armv7");
        deviceCapabilityArray.AddString("gamekit"); 

        rootDict.SetBoolean("UIRequiresFullScreen", true);

        File.WriteAllText(infoPlistPath, plist.WriteToString());
    }
Ejemplo n.º 9
0
	public static void OnPostProcessBuild (BuildTarget buildTarget, string path)
	{
		#if UNITY_ANDROID

		#elif UNITY_IPHONE
		string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
		PBXProject pbxProj = new PBXProject ();
		pbxProj.ReadFromFile (projPath);
		string target = pbxProj.TargetGuidByName (PBXProject.GetUnityTargetName ());

		pbxProj.AddFrameworkToProject (target, "AssetsLibrary.framework", false);
		pbxProj.AddFrameworkToProject (target, "AudioToolbox.framework", false);
		pbxProj.AddFrameworkToProject (target, "AVFoundation.framework", false);
		pbxProj.AddFrameworkToProject (target, "CFNetwork.framework", false);
		pbxProj.AddFrameworkToProject (target, "CoreAudio.framework", false);
		pbxProj.AddFrameworkToProject (target, "CoreLocation.framework", false);
		pbxProj.AddFrameworkToProject (target, "CoreMedia.framework", false);
		pbxProj.AddFrameworkToProject (target, "CoreTelephony.framework", false);
		pbxProj.AddFrameworkToProject (target, "CoreVideo.framework", false);
		pbxProj.AddFrameworkToProject (target, "CoreGraphics.framework", false);
		pbxProj.AddFrameworkToProject (target, "ImageIO.framework", false);

		pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libc++.dylib", "Frameworks/libc++.dylib", PBXSourceTree.Sdk));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libc++abi.dylib", "Frameworks/libc++abi.dylib", PBXSourceTree.Sdk));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libsqlite3.dylib", "Frameworks/libsqlite3.dylib", PBXSourceTree.Sdk));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libstdc++.dylib", "Frameworks/libstdc++.dylib", PBXSourceTree.Sdk));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libxml2.dylib", "Frameworks/libxml2.dylib", PBXSourceTree.Sdk));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libz.dylib", "Frameworks/libz.dylib", PBXSourceTree.Sdk));

		pbxProj.AddFrameworkToProject (target, "MapKit.framework", false);
		pbxProj.AddFrameworkToProject (target, "OpenGLES.framework", false);
		pbxProj.AddFrameworkToProject (target, "QuartzCore.framework", false);
		pbxProj.AddFrameworkToProject (target, "SystemConfiguration.framework", false);
		pbxProj.AddFrameworkToProject (target, "UIKit.framework", false);

		DirectoryInfo di = new DirectoryInfo (Application.dataPath);
		string rongCloudLibFloder = Path.Combine (di.Parent.FullName, "RongCloudLib");




		CopyAndReplaceDirectory(Path.Combine (rongCloudLibFloder, "RongIMLib.framework"), Path.Combine(path, "Frameworks/RongIMLib.framework"));
		pbxProj.AddFileToBuild(target, pbxProj.AddFile("Frameworks/RongIMLib.framework", "Frameworks/RongIMLib.framework", PBXSourceTree.Source));


//		pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (rongCloudLibFloder, "RongIMLib.framework"), "Frameworks/RongIMLib.framework", PBXSourceTree.Absolute));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/RongCloudBinding.m"), "Libraries/RongCloudBinding.m", PBXSourceTree.Absolute));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/RongCloudManager.m"), "Libraries/RongCloudManager.m", PBXSourceTree.Absolute));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/RongCloudManager.h"), "Libraries/RongCloudManager.h", PBXSourceTree.Absolute));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/GroupOperationMessage.h"), "Libraries/GroupOperationMessage.h", PBXSourceTree.Absolute));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/GroupOperationMessage.m"), "Libraries/GroupOperationMessage.m", PBXSourceTree.Absolute));

		pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/GroupRequestMessage.h"), "Libraries/GroupRequestMessage.h", PBXSourceTree.Absolute));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/GroupRequestMessage.m"), "Libraries/GroupRequestMessage.m", PBXSourceTree.Absolute));



		pbxProj.SetBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(inherited)");
		pbxProj.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)/Frameworks");

		pbxProj.WriteToFile (projPath);
		PlistDocument plist = new PlistDocument ();
		string plistPath = Path.Combine (path, "Info.plist");
		plist.ReadFromFile (plistPath);
		var deviceCapabilities = plist.root ["UIRequiredDeviceCapabilities"].AsArray ();
		deviceCapabilities.AddString ("front-facing-camera");
		deviceCapabilities.AddString ("video-camera");
//		plist.root.SetBoolean ("LSHasLocalizedDisplayName", true);

		plist.WriteToFile (plistPath);
		#endif

	}
Ejemplo n.º 10
0
        private static PlistElement ReadElement(XElement xml)
        {
            string localName = xml.Name.LocalName;

            if (localName != null)
            {
                Dictionary <string, int> types = new Dictionary <string, int>(8)
                {
                    {
                        "dict",
                        0
                    },
                    {
                        "array",
                        1
                    },
                    {
                        "string",
                        2
                    },
                    {
                        "integer",
                        3
                    },
                    {
                        "real",
                        4
                    },
                    {
                        "date",
                        5
                    },
                    {
                        "true",
                        6
                    },
                    {
                        "false",
                        7
                    }
                };

                int num = 0;
                if (types.TryGetValue(localName, out num))
                {
                    switch (num)
                    {
                    case 0:
                        List <XElement>  list1            = Enumerable.ToList <XElement>(xml.Elements());
                        PlistElementDict plistElementDict = new PlistElementDict();
                        if (list1.Count % 2 == 1)
                        {
                            throw new Exception("Malformed plist file");
                        }
                        for (int index1 = 0; index1 < list1.Count - 1; ++index1)
                        {
                            if (list1[index1].Name != (XName)"key")
                            {
                                throw new Exception("Malformed plist file. Found '" + (object)list1[index1].Name + "' where 'key' was expected.");
                            }
                            string       index2       = PlistDocument.GetText(list1[index1]).Trim();
                            PlistElement plistElement = PlistDocument.ReadElement(list1[index1 + 1]);
                            if (plistElement != null)
                            {
                                ++index1;
                                plistElementDict[index2] = plistElement;
                            }
                        }
                        return((PlistElement)plistElementDict);

                    case 1:
                        List <XElement>   list2             = Enumerable.ToList <XElement>(xml.Elements());
                        PlistElementArray plistElementArray = new PlistElementArray();
                        foreach (XElement xml1 in list2)
                        {
                            PlistElement plistElement = PlistDocument.ReadElement(xml1);
                            if (plistElement != null)
                            {
                                plistElementArray.values.Add(plistElement);
                            }
                        }
                        return((PlistElement)plistElementArray);

                    case 2:
                        return((PlistElement) new PlistElementString(PlistDocument.GetText(xml)));

                    case 3:
                        int result1;
                        if (int.TryParse(PlistDocument.GetText(xml), out result1))
                        {
                            return((PlistElement) new PlistElementInteger(result1));
                        }
                        return((PlistElement)null);

                    case 4:
                        float result2;
                        if (float.TryParse(PlistDocument.GetText(xml), out result2))
                        {
                            return((PlistElement) new PlistElementReal(result2));
                        }
                        return((PlistElement)null);

                    case 5:
                        DateTime result3;
                        if (DateTime.TryParse(PlistDocument.GetText(xml), out result3))
                        {
                            return((PlistElement) new PlistElementDate(result3.ToUniversalTime()));
                        }
                        return((PlistElement)null);

                    case 6:
                        return((PlistElement) new PlistElementBoolean(true));

                    case 7:
                        return((PlistElement) new PlistElementBoolean(false));
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 11
0
 internal static string CleanDtdToString(XDocument doc)
 {
     return(PlistDocument.CleanDtdToString(doc, doc.DocumentType));
 }
    //info.plistを取得
    private static PlistDocument GetInfoPlist(string buildPath)
    {
        string plistPath = GetInfoPlistPath(buildPath);
        PlistDocument plist = new PlistDocument();
        plist.ReadFromFile(plistPath);

        return plist;
    }
Ejemplo n.º 13
0
        private static PlistElement ReadElement(XElement xml)
        {
            string localName = xml.Name.LocalName;
            // ISSUE: reference to a compiler-generated method
            uint stringHash = PrivateImplementationDetails.ComputeStringHash(localName);

            if (stringHash <= 1303515621U)
            {
                if (stringHash <= 398550328U)
                {
                    if ((int)stringHash != 184981848)
                    {
                        if ((int)stringHash == 398550328 && localName == "string")
                        {
                            return((PlistElement) new PlistElementString(PlistDocument.GetText(xml)));
                        }
                    }
                    else if (localName == "false")
                    {
                        return((PlistElement) new PlistElementBoolean(false));
                    }
                }
                else if ((int)stringHash != 1278716217)
                {
                    if ((int)stringHash == 1303515621 && localName == "true")
                    {
                        return((PlistElement) new PlistElementBoolean(true));
                    }
                }
                else if (localName == "dict")
                {
                    List <XElement>  list             = Enumerable.ToList <XElement>(xml.Elements());
                    PlistElementDict plistElementDict = new PlistElementDict();
                    if (list.Count % 2 == 1)
                    {
                        throw new Exception("Malformed plist file");
                    }
                    for (int index1 = 0; index1 < list.Count - 1; ++index1)
                    {
                        if (list[index1].Name != (XName)"key")
                        {
                            throw new Exception("Malformed plist file. Found '" + (object)list[index1].Name + "' where 'key' was expected.");
                        }
                        string       index2       = PlistDocument.GetText(list[index1]).Trim();
                        PlistElement plistElement = PlistDocument.ReadElement(list[index1 + 1]);
                        if (plistElement != null)
                        {
                            ++index1;
                            plistElementDict[index2] = plistElement;
                        }
                    }
                    return((PlistElement)plistElementDict);
                }
            }
            else if (stringHash <= 3218261061U)
            {
                if ((int)stringHash != -1973899994)
                {
                    int result;
                    if ((int)stringHash == -1076706235 && localName == "integer" && int.TryParse(PlistDocument.GetText(xml), out result))
                    {
                        return((PlistElement) new PlistElementInteger(result));
                    }
                }
                else if (localName == "array")
                {
                    List <XElement>   list = Enumerable.ToList <XElement>(xml.Elements());
                    PlistElementArray plistElementArray = new PlistElementArray();
                    foreach (XElement xml1 in list)
                    {
                        PlistElement plistElement = PlistDocument.ReadElement(xml1);
                        if (plistElement != null)
                        {
                            plistElementArray.values.Add(plistElement);
                        }
                    }
                    return((PlistElement)plistElementArray);
                }
            }
            else if ((int)stringHash != -730669991)
            {
                float result;
                if ((int)stringHash == -689983395 && localName == "real" && float.TryParse(PlistDocument.GetText(xml), out result))
                {
                    return((PlistElement) new PlistElementReal(result));
                }
            }
            else
            {
                DateTime result;
                if (localName == "date" && DateTime.TryParse(PlistDocument.GetText(xml), out result))
                {
                    return((PlistElement) new PlistElementDate(result.ToUniversalTime()));
                }
            }
            return((PlistElement)null);
        }
    static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        if (buildTarget != BuildTarget.iOS) return;

        /*------------------------------------------------------*/
        // for frameworks

        string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
        Debug.Log("Build iOS. path: " + projPath);

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

        string target = proj.TargetGuidByName("Unity-iPhone");
        //		string debugConfig = proj.BuildConfigByName(target, "Debug");
        //		string releaseConfig = proj.BuildConfigByName(target, "Release");

        // Add custom system frameworks. Duplicate frameworks are ignored.
        // needed by our native plugin in Assets/Plugins/iOS
        //		proj.AddFrameworkToProject(target, ".framework", false /*not weak*/);

        // Add usr/lib
        string framenwork1 = "libz.dylib";
        string framenwork2 = "libsqlite3.0.dylib";
        string fileGuid1 = proj.AddFile ("usr/lib/"+framenwork1, "Frameworks/"+framenwork1, PBXSourceTree.Sdk);
        string fileGuid2 = proj.AddFile ("usr/lib/"+framenwork2, "Frameworks/"+framenwork2, PBXSourceTree.Sdk);
        proj.AddFileToBuild (target, fileGuid1);
        proj.AddFileToBuild (target, fileGuid2);

        // Add our framework directory to the framework include path
        proj.SetBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(inherited)");
        proj.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)/Frameworks");
        //		proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
        proj.AddBuildProperty(target, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");

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

        /*------------------------------------------------------*/
        // for Info.plist

        // PlistDocument
        // http://docs.unity3d.com/ScriptReference/iOS.Xcode.PlistDocument.html

        // Get plist
        var plistPath = Path.Combine(path, "Info.plist");
        var plist = new PlistDocument();
        plist.ReadFromFile(plistPath);

        // Get root
        PlistElementDict rootDict = plist.root;

        // Create URL types
        string identifier = PlayerPrefs.GetString ("identifier");
        string scheme = PlayerPrefs.GetString ("scheme");

        PlistElementArray urlTypesArray = rootDict.CreateArray ("CFBundleURLTypes");
        PlistElementDict dict = urlTypesArray.AddDict ();
        dict.SetString ("CFBundleURLName", identifier);
        PlistElementArray schemesArray = dict.CreateArray ("CFBundleURLSchemes");
        schemesArray.AddString (scheme);

        //		PlistElementArray urlTypesArray = rootDict.CreateArray ("CFBundleURLTypes");
        //		PlistElementDict dict = urlTypesArray.AddDict ();
        //		dict.SetString ("CFBundleURLName", "com.unitybuild.test");
        //		PlistElementArray schemesArray = dict.CreateArray ("CFBundleURLSchemes");
        //		schemesArray.AddString ("myscheme");

        // Write to file
        File.WriteAllText(plistPath, plist.WriteToString());
    }
Ejemplo n.º 15
0
 public void ReadFromString(string text)
 {
     this.m_Doc = PlistDocument.ParseXmlNoDtd(text);
 }
Ejemplo n.º 16
0
 public string WriteToString()
 {
     return(PlistDocument.CleanDtdToString(this.m_Doc, (XDocumentType)null).Replace("\r\n", "\n"));
 }
	public static void PatchInfoPlist(string pathToBuiltProject)
	{
		string plistPath = Path.Combine(pathToBuiltProject, "Info.plist");
		
		PlistDocument plist = new PlistDocument();
		plist.ReadFromFile(plistPath);
		
		
		// =================================
		// We must do this here instead of passing the plist to
		//  a useful helper function because Unity refuses to build functions
		//  where a variable of type PlistDocument is passed.
		
		string key = "UISupportedExternalAccessoryProtocols";
		string[] values = new string[3]
		{
			"io.structure.control",
			"io.structure.depth",
			"io.structure.infrared"
		};
		
		if (plist.root.values.ContainsKey(key))
			return;
		
		PlistElementArray array = new PlistElementArray();
		foreach (string value in values)
			array.AddString(value);
		
		plist.root.values.Add (new PlistEntry(key, array));
		// =================================
		
		
		plist.root.values.Add( new PlistEntry("UIFileSharingEnabled", new PlistElementBoolean(true) ) );
		
		
		plist.WriteToFile(plistPath);
	}
Ejemplo n.º 18
0
        private void GenerateIOSAirshipConfig()
        {
            string plistPath = Path.Combine (Application.dataPath, "Plugins/iOS/AirshipConfig.plist");
            if (File.Exists (plistPath)) {
                File.Delete (plistPath);
            }

            PlistDocument plist = new PlistDocument ();

            PlistElementDict rootDict = plist.root;

            if (!String.IsNullOrEmpty (ProductionAppKey) && !String.IsNullOrEmpty (ProductionAppSecret)) {
                rootDict.SetString ("productionAppKey", ProductionAppKey);
                rootDict.SetString ("productionAppSecret", ProductionAppSecret);
                rootDict.SetInteger ("productionLogLevel", IOSLogLevel (ProductionLogLevel));
            }

            if (!String.IsNullOrEmpty (DevelopmentAppKey) && !String.IsNullOrEmpty (DevelopmentAppSecret)) {
                rootDict.SetString ("developmentAppKey", DevelopmentAppKey);
                rootDict.SetString ("developmentAppSecret", DevelopmentAppSecret);
                rootDict.SetInteger ("developmentLogLevel", IOSLogLevel (DevelopmentLogLevel));
            }

            rootDict.SetBoolean ("inProduction", InProduction);

            PlistElementDict customConfig = rootDict.CreateDict ("customConfig");
            customConfig.SetBoolean ("notificationPresentationOptionAlert", NotificationPresentationOptionAlert);
            customConfig.SetBoolean ("notificationPresentationOptionBadge", NotificationPresentationOptionBadge);
            customConfig.SetBoolean ("notificationPresentationOptionSound", NotificationPresentationOptionSound);

            File.WriteAllText (plistPath, plist.WriteToString ());
        }
Ejemplo n.º 19
0
        private static void UpdateProjectPlist(string plistPath)
        {
            PlistDocument plist = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));

            PlistElementDict rootDict = plist.root;
            rootDict.CreateArray("UIBackgroundModes").AddString("remote-notification");

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