From b0056b932b830efd6da2df9aa871ffceb5873114 Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期二, 23 十月 2018 17:19:27 +0800
Subject: [PATCH] 4308  支持不同的渠道自定义登录背景(动态效果或者一张指定的静态图)

---
 Assets/Editor/XCodeProjectMod.cs |   58 +++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 45 insertions(+), 13 deletions(-)

diff --git a/Assets/Editor/XCodeProjectMod.cs b/Assets/Editor/XCodeProjectMod.cs
index 526535a..05c1f74 100644
--- a/Assets/Editor/XCodeProjectMod.cs
+++ b/Assets/Editor/XCodeProjectMod.cs
@@ -2,18 +2,18 @@
 using System.IO;
 using UnityEditor;
 using UnityEditor.iOS.Xcode.Custom;
+using UnityEditor.iOS.Xcode.Custom.Extensions;
 using UnityEngine;
 
 public class XCodeProjectMod
 {
-
+#if UNITY_IOS
     private const string CODE_SIGN_DEVELOPER = "";
     private const string CODE_SIGN_DISTRIBUTION = "";
     private const string PROVISIONING_DEVELOPER = "";
     private const string PROVISIONING_DISTRIBUTION = "";
     private const string TEAM = "5X26T385YZ";
 
-#if UNITY_IOS
     [UnityEditor.Callbacks.PostProcessBuild(999)]
     public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
     {
@@ -21,8 +21,6 @@
         {
             return;
         }
-
-
 
         string _projectPath = PBXProject.GetPBXProjectPath(path);
 
@@ -66,8 +64,11 @@
         _project.AddFileToBuild(_targetGUID, _project.AddFile("/usr/lib/libiconv.tbd", "Frameworks/libiconv.tbd", PBXSourceTree.Sdk));
         _project.AddFileToBuild(_targetGUID, _project.AddFile("/usr/lib/libresolv.tbd", "Frameworks/libresolv.tbd", PBXSourceTree.Sdk));
 
-        // 閽堝鐚効sdk鐨勫鐞�
-        HandleMrSDK(_project);
+        // mr_sdk
+        HandleMrSDK(_project, _targetGUID);
+
+        // sp_sdk
+        HandleSpSDK(_project, _targetGUID);
 
         File.WriteAllText(_projectPath, _project.WriteToString());
 
@@ -83,7 +84,6 @@
             ModifyFile(path);
         }
     }
-#endif
 
     private static void BuildPlist(string path)
     {
@@ -111,12 +111,24 @@
 
     private static void ModifyFile(string projectPath)
     {
+        bool _isMr = false;
+        string _mrPlistPath = Application.dataPath + "/Plugins/iOS/MyMRSDK/MRSDKInfo.plist";
+        if (File.Exists(_mrPlistPath))
+        {
+            _isMr = true;
+        }
+
         // -------------- UnityAppController.mm
         //璇诲彇UnityAppController.mm鏂囦欢
         var _xclass = new XClass(projectPath + "/Classes/UnityAppController.mm");
 
         //鍦ㄦ寚瀹氫唬鐮佸悗闈㈠鍔犱竴琛屼唬鐮�
-        _xclass.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#include \"UniversalSDK.h\"\n#include \"JPushService.h\"");
+        _xclass.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#include \"UniversalSDK.h\"\n#include \"JPushService.h\"\n");
+
+        if (_isMr)
+        {
+            _xclass.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#include \"IAPManager.h\"\n");
+        }
 
         string newCode = "\n" +
                          "extern \"C\" void IOSMessageHandle(const char* jsonString) {\n" +
@@ -132,7 +144,17 @@
         //鍦ㄦ寚瀹氫唬鐮佸悗闈㈠鍔犱竴澶ц浠g爜
         _xclass.WriteBelow("[KeyboardDelegate Initialize];", newCode);
 
+        if (_isMr)
+        {
+            _xclass.WriteBelow("[KeyboardDelegate Initialize];", "    [[IAPManager shared] startManager];\n");
+        }
+
         _xclass.WriteBelow("UnitySendDeviceToken(deviceToken);", "    [JPUSHService registerDeviceToken:deviceToken];");
+
+        if (_isMr)
+        {
+            _xclass.WriteBelow("SensorsCleanup();", "    [[IAPManager shared] stopManager];");
+        }
 
         newCode = "UnitySendRemoteNotification(userInfo);\n" +
             "    [JPUSHService handleRemoteNotification:userInfo];\n";
@@ -241,7 +263,6 @@
         BuildPipeline.BuildPlayer(ClientPackage.baseLevels, GetBuildPath(), BuildTarget.iOS, BuildOptions.Il2CPP);
     }
 
-#if UNITY_IOS
     [MenuItem("Build/ipa")]
     public static void BuildIPA()
     {
@@ -256,16 +277,27 @@
         _p.Start();
         _p.WaitForExit();
     }
-#endif
 
-    private static void HandleMrSDK(PBXProject project)
+    private static void HandleMrSDK(PBXProject project, string targetGUID)
     {
         string _mrPlistPath = Application.dataPath + "/Plugins/iOS/MyMRSDK/MRSDKInfo.plist";
         if (File.Exists(_mrPlistPath))
         {
-            string _targetGUID = project.TargetGuidByName(UnityEditor.iOS.Xcode.PBXProject.GetUnityTargetName());
             string _fileGUID = project.AddFile(_mrPlistPath, "Frameworks/Plugins/iOS/MyMRSDK/MRSDKInfo.plist");
-            project.AddFileToBuild(_targetGUID, _fileGUID);
+            project.AddFileToBuild(targetGUID, _fileGUID);
         }
     }
+
+    private static void HandleSpSDK(PBXProject project, string targetGUID)
+    {
+        string _filePath = Application.dataPath + "/Plugins/iOS/SPYOUSDK/GDTActionSDK.framework";
+        if (Directory.Exists(_filePath))
+        {
+            string _frameworkGUID = project.FindFileGuidByProjectPath("Frameworks/Plugins/iOS/SPYOUSDK/GDTActionSDK.framework");
+            PBXProjectExtensions.AddFileToEmbedFrameworks(project, targetGUID, _frameworkGUID);
+        }
+    }
+
+#endif
+
 }

--
Gitblit v1.8.0