コード例 #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
    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());
        }
    }
コード例 #3
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());
    }
コード例 #4
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 ());
        }
コード例 #5
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());
        }
コード例 #6
0
    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());
    }
コード例 #7
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());
        }