コード例 #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
    }
コード例 #2
0
ファイル: PostBuild.cs プロジェクト: Appboy/appboy-unity-sdk
        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());
        }
コード例 #3
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));
    }
コード例 #4
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());
        }
    }
コード例 #5
0
ファイル: Postprocessor.cs プロジェクト: li5414/Parachute2D
    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());
    }
コード例 #6
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());
        }