From 800e5780b3dcfc36327c2f95ef69ea81b5294264 Mon Sep 17 00:00:00 2001
From: allez <305670599@qq.com>
Date: 星期五, 05 三月 2021 15:26:54 +0800
Subject: [PATCH] 9527 ios打包配置
---
Assets/Editor/Tool/ClientPackage.cs | 4
Assets/Editor/XCodeProjectMod.cs | 147 ++++++++++--------------------------------------
Assets/Editor/XClass.cs | 24 ++++++++
3 files changed, 57 insertions(+), 118 deletions(-)
diff --git a/Assets/Editor/Tool/ClientPackage.cs b/Assets/Editor/Tool/ClientPackage.cs
index ac41546..43b624c 100644
--- a/Assets/Editor/Tool/ClientPackage.cs
+++ b/Assets/Editor/Tool/ClientPackage.cs
@@ -42,7 +42,7 @@
static string THE_2TH_WORLD_SDK_PATH = Application.dataPath + "/Plugins/Android/bin";
// static string MANIFEST_PATH = Application.dataPath + "/Plugins/Android/AndroidManifest.xml";
- static string iOS_PLUGIN_PATH = Application.dataPath + "/Plugins/iOS";
+ static string iOS_PLUGIN_PATH = Application.dataPath + "/Plugins/iOS/Channel";
/// <summary>
/// 鎵撳寘
@@ -504,7 +504,7 @@
// if (!versionConfig.appId.Equals("test"))
// {
- FileExtersion.DirectoryCopy(StringUtility.Contact(_sdkPath, "/ChannelDiff/iOS/", versionConfig.appId), iOS_PLUGIN_PATH);
+ FileExtersion.DirectoryCopy(StringUtility.Contact(_sdkPath, "/Channel/iOS/", versionConfig.appId,"/Plugins"), iOS_PLUGIN_PATH);
// }
DateTime outTime;
diff --git a/Assets/Editor/XClass.cs b/Assets/Editor/XClass.cs
index 1a0325d..1722aac 100644
--- a/Assets/Editor/XClass.cs
+++ b/Assets/Editor/XClass.cs
@@ -21,6 +21,30 @@
}
}
+ //鍦ㄦ寚瀹氫唬鐮佷笂鏂规彃鍏�
+ //public void WriteAbove(string below,string text)
+ //{
+ // StreamReader streamReader = new StreamReader(filePath);
+ // string text_all = streamReader.ReadToEnd();
+ // streamReader.Close();
+
+ // int beginIndex = text_all.IndexOf(below, System.StringComparison.CurrentCulture);
+ // if (beginIndex == -1)
+ // {
+ // Debug.LogError(filePath + "涓病鏈夋壘鍒版爣鑷�" + below);
+ // return;
+ // }
+
+ // int endIndex = text_all.LastIndexOf("\n", beginIndex + below.Length, System.StringComparison.CurrentCulture);
+
+ // text_all = text_all.Substring(0, endIndex) + "\n" + text + "\n" + text_all.Substring(endIndex);
+
+ // StreamWriter streamWriter = new StreamWriter(filePath);
+ // streamWriter.Write(text_all);
+ // streamWriter.Close();
+ //}
+
+ //鍦ㄦ寚瀹氫唬鐮佷笅鏂规彃鍏�
public void WriteBelow(string below, string text)
{
StreamReader streamReader = new StreamReader(filePath);
diff --git a/Assets/Editor/XCodeProjectMod.cs b/Assets/Editor/XCodeProjectMod.cs
index 7fe6d30..ed86aed 100644
--- a/Assets/Editor/XCodeProjectMod.cs
+++ b/Assets/Editor/XCodeProjectMod.cs
@@ -64,18 +64,13 @@
_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));
- // mr_sdk
- HandleMrSDK(_project, _targetGUID);
-
- // sp_sdk
- HandleSpSDK(_project, _targetGUID);
-
File.WriteAllText(_projectPath, _project.WriteToString());
- var _capabilityMgr = new ProjectCapabilityManager(_projectPath, "game003.entitlements", PBXProject.GetUnityTargetName());
- _capabilityMgr.AddInAppPurchase();
- _capabilityMgr.AddPushNotifications(true);
- _capabilityMgr.WriteToFile();
+ //鍔犳帹閫�
+ //var _capabilityMgr = new ProjectCapabilityManager(_projectPath, "game003.entitlements", PBXProject.GetUnityTargetName());
+ //_capabilityMgr.AddInAppPurchase();
+ //_capabilityMgr.AddPushNotifications(true);
+ //_capabilityMgr.WriteToFile();
BuildPlist(path);
@@ -111,104 +106,44 @@
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鏂囦欢
+ //淇敼UnityAppController.mm 鏂囦欢
var _xclass = new XClass(projectPath + "/Classes/UnityAppController.mm");
-
- //鍦ㄦ寚瀹氫唬鐮佸悗闈㈠鍔犱竴琛屼唬鐮�
- _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");
- }
-
+ //寮曞叆UniversalSDK
+ _xclass.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#include \"UniversalSDK.h\""+ "\n#import <SMPCQuickSDK/SMPCQuickSDK.h>");
+ //unity浜や簰璋冪敤鐨勬柟娉�
string newCode = "\n" +
- "extern \"C\" void IOSMessageHandle(const char* jsonString) {\n" +
- " [GetAppController().universalSDK HandleUnityMessage:[NSString stringWithUTF8String:jsonString]];\n" +
- "}";
- _xclass.WriteBelow("extern \"C\" ScreenOrientation UnityCurrentOrientation() { return GetAppController().unityView.contentOrientation; }",
- newCode);
-
+ "extern \"C\" void IOSMessageHandle(const char* jsonString) {\n" +
+ " [GetAppController().universalSDK HandleUnityMessage:[NSString stringWithUTF8String:jsonString]];\n" +
+ "}";
+ _xclass.WriteBelow("extern \"C\" ScreenOrientation UnityCurrentOrientation() { return GetAppController().unityView.contentOrientation; }",newCode);
+ //鍒濆鍖朥niversalSDK
newCode = "\n" +
- " _universalSDK = [[UniversalSDK alloc] init];\n" +
- " [_universalSDK JPushInit:launchOptions];";
-
- //鍦ㄦ寚瀹氫唬鐮佸悗闈㈠鍔犱竴澶ц浠g爜
+ " _universalSDK = [[UniversalSDK alloc] init];\n";
_xclass.WriteBelow("[KeyboardDelegate Initialize];", newCode);
+ //quick sdk 鐢熷懡鍛ㄦ湡
+ _xclass.WriteBelow("supportedInterfaceOrientationsForWindow:(UIWindow*)window\n{", "[[SMPCQuickSDK defaultInstance] application:application supportedInterfaceOrientationsForWindow:window];");
+ _xclass.WriteBelow("UnitySendRemoteNotification(userInfo);", "[[SMPCQuickSDK defaultInstance] application:application didReceiveRemoteNotification:userInfo];");
+ _xclass.WriteBelow("UnitySendDeviceToken(deviceToken);", "[[SMPCQuickSDK defaultInstance] application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];");
+ _xclass.WriteBelow("UnitySendRemoteNotificationError(error);", "[[SMPCQuickSDK defaultInstance] application:application didFailToRegisterForRemoteNotificationsWithError:error];");
+ _xclass.WriteBelow("- (BOOL)application:(UIApplication*)app openURL:(NSURL*)url options:(NSDictionary<NSString*, id>*)options\n{", "[[SMPCQuickSDK defaultInstance] openURL:url application:app options:options];");
+ _xclass.WriteBelow("::printf(\"-> applicationDidEnterBackground()\\n\");", "[[SMPCQuickSDK defaultInstance] applicationDidEnterBackground:application];");
+ _xclass.WriteBelow("::printf(\"-> applicationWillEnterForeground()\\n\");", "[[SMPCQuickSDK defaultInstance] applicationWillEnterForeground:application];");
+ _xclass.WriteBelow("::printf(\"-> applicationDidBecomeActive()\\n\");", "[[SMPCQuickSDK defaultInstance] applicationDidBecomeActive:application];");
+ _xclass.WriteBelow("::printf(\"-> applicationWillResignActive()\\n\");", "[[SMPCQuickSDK defaultInstance] applicationWillResignActive:application];");
+ _xclass.WriteBelow("::printf(\"-> applicationWillTerminate()\\n\");", "[[SMPCQuickSDK defaultInstance] applicationWillTerminate:application];");
- 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";
-
- _xclass.Replace("UnitySendRemoteNotification(userInfo);", newCode);
-
- newCode = "[application setApplicationIconBadgeNumber:0];\n" +
- " [application cancelAllLocalNotifications];\n";
-
- _xclass.WriteBelow("::printf(\"-> applicationWillEnterForeground()\\n\");", newCode);
- _xclass.WriteBelow("::printf(\"-> applicationDidEnterBackground()\\n\");", "[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];\n");
-
- newCode = " CGRect _winSize = [UIScreen mainScreen].bounds;\n" +
- " if(KIsiPhoneX){\n" +
- " _winSize.origin.x = 40;\n" +
- " _winSize.size.width -= 92;\n" +
- " _winSize.size.height -= 15;\n" +
- " }\n" +
- " _window = [[UIWindow alloc] initWithFrame:_winSize];\n";
-
- _xclass.Replace("_window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen].bounds];", newCode);
- // -------------- UnityAppController.h
-
+ //淇敼UnityAppController.h 鏂囦欢
_xclass = new XClass(projectPath + "/Classes/UnityAppController.h");
-
- _xclass.WriteBelow("@class DisplayConnection;", "@class UniversalSDK;");
- _xclass.WriteBelow("// auto-rotation view contoller goes to index=0", "UniversalSDK* _universalSDK;");
+ _xclass.WriteBelow("@class DisplayConnection;", "@class UniversalSDK;");
+ _xclass.WriteBelow("DisplayConnection* _mainDisplay;", "UniversalSDK* _universalSDK;");
_xclass.WriteBelow("@property (readonly, copy, nonatomic) DisplayConnection* mainDisplay;",
"@property (readonly, copy, nonatomic) UniversalSDK* universalSDK;");
- _xclass = new XClass(projectPath + "/Classes/UI/UnityView.mm");
- _xclass.WriteBelow("#include \"Unity/UnityMetalSupport.h\"", "#include \"UniversalSDK.h\"");
- _xclass.WriteBelow("_curOrientation = OrientationAfterTransform(_curOrientation, TransformBetweenOrientations(from, to));",
- @"if(KIsiPhoneX) {
- CGRect _winSize = [UIScreen mainScreen].bounds;
- if(to == landscapeLeft){
- _winSize.origin.x = 0;
- _winSize.origin.y = 0;
- _winSize.size.width = 720;
- _winSize.size.height = 360;
- }else if(to == landscapeRight){
- _winSize.origin.x = 0;
- _winSize.origin.y = -15;
- _winSize.size.width = 720;
- _winSize.size.height = 360;
- }
- [self setFrame:_winSize];
- }");
-
-
- _xclass = new XClass(projectPath + "/Classes/UI/UnityViewControllerBaseiOS.mm");
+ //閫傞厤iPhoneX 搴曢儴鐧芥潯
+ _xclass = new XClass(projectPath + "/Classes/UI/UnityViewControllerBase+iOS.mm");
_xclass.Replace("return res;", "return UIRectEdgeAll;");
-
}
private static string GetBuildPath()
@@ -277,26 +212,6 @@
_p.StartInfo.RedirectStandardOutput = false;
_p.Start();
_p.WaitForExit();
- }
-
- private static void HandleMrSDK(PBXProject project, string targetGUID)
- {
- string _mrPlistPath = Application.dataPath + "/Plugins/iOS/MyMRSDK/MRSDKInfo.plist";
- if (File.Exists(_mrPlistPath))
- {
- string _fileGUID = project.AddFile(_mrPlistPath, "Frameworks/Plugins/iOS/MyMRSDK/MRSDKInfo.plist");
- 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