From 970df5ba2dd630f709daa8bc9753cb9bca073eaf Mon Sep 17 00:00:00 2001
From: macos <644869767@qq.com>
Date: 星期二, 16 六月 2026 23:12:15 +0800
Subject: [PATCH] 0312 ios 打包

---
 Assets/Editor/XCodeProjectMod.cs |  319 +++++++++++++++++++---------------------------------
 1 files changed, 116 insertions(+), 203 deletions(-)

diff --git a/Assets/Editor/XCodeProjectMod.cs b/Assets/Editor/XCodeProjectMod.cs
index 22b6a9b..59c3ba3 100644
--- a/Assets/Editor/XCodeProjectMod.cs
+++ b/Assets/Editor/XCodeProjectMod.cs
@@ -1,5 +1,4 @@
-锘縰sing DG.Tweening.Plugins.Core.PathCore;
-using System;
+锘縰sing System;
 using System.Collections.Generic;
 using System.IO;
 using UnityEditor;
@@ -8,11 +7,8 @@
 
 public class XCodeProjectMod
 {
-    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 = "";
+    // Channel 鎻掍欢瀛樻斁鐩綍锛圔uildIpa 鍓嶇敱 ClientPackage.BuildIpa 浠� _sdkPath 鎷疯礉鍒� Assets/Plugins/iOS/Channel锛�
+    private static readonly string iOSPluginPath = Application.dataPath + "/Plugins/iOS/Channel";
 
     [UnityEditor.Callbacks.PostProcessBuild(999)]
     public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
@@ -27,8 +23,13 @@
         BuildPlist(path);
         ModifyFile(path);
 
-
-       
+        // 鐢熸垚 .xcworkspace 缁撴瀯锛屾柟渚垮紑鍙戣�呭湪 Xcode 涓墜鍔� Add Package Dependency
+        // SPM 渚濊禆蹇呴』閫氳繃 .xcworkspace 绠$悊锛�.xcodeproj 鍗曠嫭鏃犳硶姝g‘ resolve
+        // 寮�鍙戣�呴渶鍦� Xcode 涓墜鍔� File 鈫� Add Package Dependency 娣诲姞浠ヤ笅浠撳簱锛屽苟閫夋嫨鎵�闇�鐨勪骇鍝佸寘锛�
+        //   - Firebase:  https://github.com/firebase/firebase-ios-sdk
+        //   - Facebook:  https://github.com/facebook/facebook-ios-sdk
+        //   - Adjust:    https://github.com/adjust/ios_sdk
+        CreateWorkspaceWithSPM(path);
     }
 
     static void DoPBXProject(string path)
@@ -41,11 +42,6 @@
         string targetGUID = project.TargetGuidByName(PBXProject.GetUnityTargetName());
         string fwTargetGUID = project.TargetGuidByName("UnityFramework");
 
-        // BuildSetting閲岀殑鐩稿叧璁剧疆
-        project.SetBuildProperty(project.ProjectGuid(), "ENABLE_BITCODE", "NO");
-        project.SetBuildProperty(targetGUID, "ENABLE_BITCODE", "NO");
-        project.SetBuildProperty(targetGUID, "DEVELOPMENT_TEAM", TEAM);
-
         // 1.1 鐜瑕佹眰锛歩OS 13.0 鍙婁互涓�
         project.SetBuildProperty(targetGUID, "IPHONEOS_DEPLOYMENT_TARGET", "13.0");
         project.SetBuildProperty(fwTargetGUID, "IPHONEOS_DEPLOYMENT_TARGET", "13.0");
@@ -57,46 +53,27 @@
         project.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-FIRDebugEnabled");
         project.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-FIRAnalyticsVerboseLoggingEnabled");
 
-        //wkwebview
+        // WebKit锛堟枃妗h姹傦級
         project.AddFrameworkToProject(fwTargetGUID, "WebKit.framework", true);
-
-        project.AddFrameworkToProject(fwTargetGUID, "SystemConfiguration.framework", true);
-        project.AddFrameworkToProject(fwTargetGUID, "Security.framework", true);
-        project.AddFrameworkToProject(fwTargetGUID, "JavaScriptCore.framework", true);
-        project.AddFrameworkToProject(fwTargetGUID, "Accelerate.framework", true);
-
-        // fimpfunSDK.framework 娣诲姞鍒板伐绋嬪苟璁剧疆涓� Embed & Sign
-        string fimpfunFrameworkPath = path + "/Frameworks/fimpfunSDK.framework";
-        if (Directory.Exists(fimpfunFrameworkPath))
-        {
-            string fileGuid = project.AddFile(fimpfunFrameworkPath, "Frameworks/fimpfunSDK.framework", PBXSourceTree.Source);
-            project.AddFileToBuild(fwTargetGUID, fileGuid);
-            // Embed & Sign: 娣诲姞鍒� main target 鐨� Embed Frameworks
-            project.AddFileToBuild(targetGUID, fileGuid);
-        }
-
-        // 澶勭悊 搴撴枃浠�
-        project.AddFileToBuild(fwTargetGUID, project.AddFile("/usr/lib/libz.tbd", "Frameworks/libz.tbd", PBXSourceTree.Sdk));
-        project.AddFileToBuild(fwTargetGUID, project.AddFile("/usr/lib/libsqlite3.tbd", "Frameworks/libsqlite3.tbd", PBXSourceTree.Sdk));
-        project.AddFileToBuild(fwTargetGUID, project.AddFile("/usr/lib/libc++.tbd", "Frameworks/libc++.tbd", PBXSourceTree.Sdk));
-        project.AddFileToBuild(fwTargetGUID, project.AddFile("/usr/lib/libiconv.tbd", "Frameworks/libiconv.tbd", PBXSourceTree.Sdk));
-        project.AddFileToBuild(fwTargetGUID, project.AddFile("/usr/lib/libresolv.tbd", "Frameworks/libresolv.tbd", PBXSourceTree.Sdk));
 
         //UnityFramework
         project.AddBuildProperty(fwTargetGUID, "OTHER_LDFLAGS", "-ObjC");
 
         // 娣诲姞 GoogleService-Info.plist 鍜� funshine.plist 鍒板伐绋�
-        string iosPluginPath = path + "/Libraries/Plugins/iOS/Channel";
         string[] configPlists = { "GoogleService-Info.plist", "funshine.plist" };
         foreach (var plistName in configPlists)
         {
-            string srcPath = iosPluginPath + "/" + plistName;
+            string srcPath = iOSPluginPath + "/" + plistName;
             if (File.Exists(srcPath))
             {
                 string destPath = path + "/" + plistName;
                 File.Copy(srcPath, destPath, true);
                 string fileGuid = project.AddFile(plistName, plistName, PBXSourceTree.Source);
                 project.AddFileToBuild(targetGUID, fileGuid);
+            }
+            else
+            {
+                Debug.LogWarning("[XCodeProjectMod] " + plistName + " 鏈壘鍒�: " + srcPath);
             }
         }
 
@@ -107,155 +84,44 @@
         project.AddFrameworkToProject(fwTargetGUID, "StoreKit.framework", true);
 
         File.WriteAllText(_projectPath, project.WriteToString());
-
-        // SPM 渚濊禆锛欶irebase / Facebook / Adjust锛圲nity PBXProject API 涓嶆敮鎸� SPM锛岄渶鐩存帴鎿嶄綔 pbxproj锛�
-        AddSwiftPackageDependencies(_projectPath, targetGUID);
     }
 
     /// <summary>
-    /// 鍚� pbxproj 娉ㄥ叆 Swift Package Manager 渚濊禆锛圶CRemoteSwiftPackageReference + XCSwiftPackageProductDependency锛�
-    /// 鐗堟湰鍙烽渶鏍规嵁 demo 鎴栧疄闄呴渶姹傝皟鏁�
+    /// 鐢熸垚 Unity-iPhone.xcworkspace 缁撴瀯锛屼粎鍖呭惈 contents.xcworkspacedata銆�
+    /// SPM 渚濊禆鐢卞紑鍙戣�呭湪 Xcode 涓墜鍔� File 鈫� Add Package Dependency 娣诲姞骞堕�夋嫨鎵�闇�浜у搧鍖咃細
+    ///   - Firebase:  https://github.com/firebase/firebase-ios-sdk
+    ///   - Facebook:  https://github.com/facebook/facebook-ios-sdk
+    ///   - Adjust:    https://github.com/adjust/ios_sdk
+    /// Package.resolved 鐢� Xcode 鍦� resolve 鍚庤嚜鍔ㄧ敓鎴愶紝浠g爜涓嶅仛澶勭悊銆�
     /// </summary>
-    private static void AddSwiftPackageDependencies(string projectPath, string targetGUID)
+    private static void CreateWorkspaceWithSPM(string projectPath)
     {
-        string content = File.ReadAllText(projectPath);
+        string workspacePath = projectPath + "/Unity-iPhone.xcworkspace";
+        string xcodeprojAbsPath = projectPath + "/Unity-iPhone.xcodeproj";
 
-        // ---- 1. 鐢熸垚 GUID锛堜娇鐢ㄧ‘瀹氭�у懡鍚嶉伩鍏嶉噸澶嶆敞鍏ワ級----
-        string firebasePkgRefGuid  = "FIMPSPM00001"; // XCRemoteSwiftPackageReference
-        string fbPkgRefGuid        = "FIMPSPM00002";
-        string adjustPkgRefGuid    = "FIMPSPM00003";
-
-        string firebaseAnalyticsProdGuid = "FIMPSPM00011"; // XCSwiftPackageProductDependency (FirebaseAnalytics)
-        string firebaseCoreProdGuid      = "FIMPSPM00012"; // XCSwiftPackageProductDependency (FirebaseCore)
-        string fbCoreKitProdGuid         = "FIMPSPM00021"; // XCSwiftPackageProductDependency (FacebookCore)
-        string fbLoginKitProdGuid        = "FIMPSPM00022"; // XCSwiftPackageProductDependency (FacebookLogin)
-        string adjustProdGuid            = "FIMPSPM00031"; // XCSwiftPackageProductDependency (Adjust)
-
-        // 濡傛灉宸茬粡娉ㄥ叆杩囷紝璺宠繃
-        if (content.Contains(firebasePkgRefGuid))
+        if (!Directory.Exists(xcodeprojAbsPath))
         {
-            UnityEngine.Debug.Log("[XCodeProjectMod] SPM dependencies already injected, skipping.");
+            Debug.LogWarning("[XCodeProjectMod] xcodeproj not found, skip creating workspace: " + xcodeprojAbsPath);
             return;
         }
 
-        // ---- 2. XCRemoteSwiftPackageReference section ----
-        string pkgRefSection = "/* XCRemoteSwiftPackageReference section */";
-        string pkgRefEntries = string.Format(
-            "\t\t{{0}} /* XCRemoteSwiftPackageReference \"Firebase\" */ = {{isa = XCRemoteSwiftPackageReference; repositoryURL = \"https://github.com/firebase/firebase-ios-sdk\"; requirement = {{kind = upToNextMajorVersion; minimumVersion = 10.24.0; }}; }};\n" +
-            "\t\t{{1}} /* XCRemoteSwiftPackageReference \"Facebook\" */ = {{isa = XCRemoteSwiftPackageReference; repositoryURL = \"https://github.com/facebook/facebook-ios-sdk\"; requirement = {{kind = upToNextMajorVersion; minimumVersion = 17.0.0; }}; }};\n" +
-            "\t\t{{2}} /* XCRemoteSwiftPackageReference \"Adjust\" */ = {{isa = XCRemoteSwiftPackageReference; repositoryURL = \"https://github.com/adjust/ios_sdk\"; requirement = {{kind = upToNextMajorVersion; minimumVersion = 4.38.2; }}; }};\n",
-            firebasePkgRefGuid, fbPkgRefGuid, adjustPkgRefGuid);
-        content = content.Replace(pkgRefSection, pkgRefSection + "\n" + pkgRefEntries);
+        Directory.CreateDirectory(workspacePath);
 
-        // ---- 3. XCSwiftPackageProductDependency section ----
-        string pkgProdSection = "/* XCSwiftPackageProductDependency section */";
-        string pkgProdEntries = string.Format(
-            "\t\t{{0}} /* FirebaseAnalytics */ = {{isa = XCSwiftPackageProductDependency; package = {{1}} /* XCRemoteSwiftPackageReference \"Firebase\" */; productName = FirebaseAnalytics; }};\n" +
-            "\t\t{{2}} /* FirebaseCore */ = {{isa = XCSwiftPackageProductDependency; package = {{1}} /* XCRemoteSwiftPackageReference \"Firebase\" */; productName = FirebaseCore; }};\n" +
-            "\t\t{{3}} /* FacebookCore */ = {{isa = XCSwiftPackageProductDependency; package = {{4}} /* XCRemoteSwiftPackageReference \"Facebook\" */; productName = FacebookCore; }};\n" +
-            "\t\t{{5}} /* FacebookLogin */ = {{isa = XCSwiftPackageProductDependency; package = {{4}} /* XCRemoteSwiftPackageReference \"Facebook\" */; productName = FacebookLogin; }};\n" +
-            "\t\t{{6}} /* Adjust */ = {{isa = XCSwiftPackageProductDependency; package = {{7}} /* XCRemoteSwiftPackageReference \"Adjust\" */; productName = Adjust; }};\n",
-            firebaseAnalyticsProdGuid, firebasePkgRefGuid,
-            firebaseCoreProdGuid,
-            fbCoreKitProdGuid, fbPkgRefGuid,
-            fbLoginKitProdGuid,
-            adjustProdGuid, adjustPkgRefGuid);
-        content = content.Replace(pkgProdSection, pkgProdSection + "\n" + pkgProdEntries);
+        string contentsXml = @"<?xml version=""1.0"" encoding=""UTF-8""?>
+<Workspace
+   version = ""1.0"">
+   <FileRef
+      location = ""group:Unity-iPhone.xcodeproj"">
+   </FileRef>
+</Workspace>
+";
+        File.WriteAllText(workspacePath + "/contents.xcworkspacedata", contentsXml);
 
-        // ---- 4. PBXNativeTarget packageProductDependencies ----
-        // 鍦� target 鐨� packageProductDependencies 涓坊鍔犲紩鐢�
-        string pkgProdDeps = string.Format(
-            "\t\t\t\tpackageProductDependencies = (\n" +
-            "\t\t\t\t\t{0} /* FirebaseAnalytics */,\n" +
-            "\t\t\t\t\t{1} /* FirebaseCore */,\n" +
-            "\t\t\t\t\t{2} /* FacebookCore */,\n" +
-            "\t\t\t\t\t{3} /* FacebookLogin */,\n" +
-            "\t\t\t\t\t{4} /* Adjust */,\n" +
-            "\t\t\t\t);",
-            firebaseAnalyticsProdGuid, firebaseCoreProdGuid,
-            fbCoreKitProdGuid, fbLoginKitProdGuid,
-            adjustProdGuid);
-
-        // 鎵惧埌 main target 鐨� buildPhases 缁撴潫浣嶇疆闄勮繎锛屾彃鍏� packageProductDependencies
-        // 鍦� target 鐨� buildPhases 鏁扮粍缁撴潫鍚庢坊鍔�
-        string targetMarker = targetGUID + " /* " + PBXProject.GetUnityTargetName() + " */";
-        int targetStart = content.IndexOf(targetMarker);
-        if (targetStart >= 0)
-        {
-            // 鎵惧埌杩欎釜 target dict 涓殑 buildPhases 缁撴潫鐨� );
-            int buildPhasesEnd = FindClosingParen(content, targetStart, "buildPhases");
-            if (buildPhasesEnd >= 0)
-            {
-                content = content.Insert(buildPhasesEnd, "\n" + pkgProdDeps);
-            }
-        }
-
-        // ---- 5. PBXProject packageReferences ----
-        // 鍦� project 鐨� packageReferences 涓坊鍔犲紩鐢�
-        string pkgRefs = string.Format(
-            "\t\t\t\tpackageReferences = (\n" +
-            "\t\t\t\t\t{{0}} /* XCRemoteSwiftPackageReference \"Firebase\" */,\n" +
-            "\t\t\t\t\t{{1}} /* XCRemoteSwiftPackageReference \"Facebook\" */,\n" +
-            "\t\t\t\t\t{{2}} /* XCRemoteSwiftPackageReference \"Adjust\" */,\n" +
-            "\t\t\t\t);",
-            firebasePkgRefGuid, fbPkgRefGuid, adjustPkgRefGuid);
-
-        // 鍦� PBXProject 鐨� mainGroup 鍚庨潰娣诲姞 packageReferences
-        int projectSection = content.IndexOf("/* PBXProject */ = {");
-        if (projectSection >= 0)
-        {
-            // 鎵惧埌 attributes 鍖哄潡
-            int attrsPos = content.IndexOf("attributes = {", projectSection);
-            if (attrsPos >= 0)
-            {
-                // 鍦� attributes 闂嫭鍙峰墠鎻掑叆
-                int attrsClose = content.IndexOf("};", attrsPos + 14);
-                if (attrsClose >= 0)
-                {
-                    content = content.Insert(attrsClose, "\n" + pkgRefs);
-                }
-            }
-        }
-
-        // ---- 6. PBXFrameworksBuildPhase ----
-        // 灏� SPM product 鍔犲埌 Frameworks build phase
-        string frameworkBuildPhaseMarker = "/* Frameworks */ = {";
-        int fwPhaseIdx = content.IndexOf(frameworkBuildPhaseMarker);
-        if (fwPhaseIdx >= 0)
-        {
-            int filesStart = content.IndexOf("files = (", fwPhaseIdx);
-            if (filesStart >= 0)
-            {
-                int filesEnd = content.IndexOf(");", filesStart + 9);
-                if (filesEnd >= 0)
-                {
-                    string fwEntries = string.Format(
-                        "\t\t\t\t{0} /* FirebaseAnalytics in Frameworks */,\n" +
-                        "\t\t\t\t{1} /* FirebaseCore in Frameworks */,\n" +
-                        "\t\t\t\t{2} /* FacebookCore in Frameworks */,\n" +
-                        "\t\t\t\t{3} /* FacebookLogin in Frameworks */,\n" +
-                        "\t\t\t\t{4} /* Adjust in Frameworks */,\n",
-                        firebaseAnalyticsProdGuid, firebaseCoreProdGuid,
-                        fbCoreKitProdGuid, fbLoginKitProdGuid,
-                        adjustProdGuid);
-                    content = content.Insert(filesEnd, fwEntries);
-                }
-            }
-        }
-
-        File.WriteAllText(projectPath, content);
-        UnityEngine.Debug.Log("[XCodeProjectMod] SPM dependencies (Firebase/Facebook/Adjust) injected successfully.");
-    }
-
-    /// <summary>
-    /// 鍦� pbxproj 鏂囨湰涓紝浠庢寚瀹� key锛堝 buildPhases锛夌殑鏁扮粍璧峰浣嶇疆鎵惧埌鍏堕棴鎷彿 ");" 鐨勪綅缃�
-    /// </summary>
-    private static int FindClosingParen(string content, int searchStart, string key)
-    {
-        int keyIdx = content.IndexOf(key + " = (", searchStart);
-        if (keyIdx < 0) return -1;
-        int openIdx = content.IndexOf("(", keyIdx);
-        return content.IndexOf(");", openIdx);
+        Debug.Log("[XCodeProjectMod] Unity-iPhone.xcworkspace created at: " + workspacePath);
+        Debug.Log("[XCodeProjectMod] 璇峰湪 Xcode 涓墦寮� .xcworkspace锛屾墜鍔� File 鈫� Add Package Dependency 娣诲姞 SPM 浠撳簱锛�");
+        Debug.Log("[XCodeProjectMod]   - Firebase:  https://github.com/firebase/firebase-ios-sdk");
+        Debug.Log("[XCodeProjectMod]   - Facebook:  https://github.com/facebook/facebook-ios-sdk");
+        Debug.Log("[XCodeProjectMod]   - Adjust:    https://github.com/adjust/ios_sdk");
     }
 
     private static void BuildPlist(string path)
@@ -270,8 +136,8 @@
 
         // Facebook (funshine.plist: kFacebookAppID / kFacebookAppSecret)
         _rootDict.SetString("FacebookAppID", "1445747540428317");
-        _rootDict.SetString("FacebookClientToken", "");
-        _rootDict.SetString("FacebookDisplayName", "Legend of the Sword Master");
+        _rootDict.SetString("FacebookClientToken", "1103765897fb67ffc898e6a8ee2d9aec");
+        _rootDict.SetString("FacebookDisplayName", "EZ PZ: Byte Heroes");
 
         // 閫傞厤娆х洘鍦板尯鏀跨瓥娉曡 - Google Analytics 榛樿鍏佽
         _rootDict.SetBoolean("GOOGLE_ANALYTICS_DEFAULT_ALLOW_ANALYTICS_STORAGE", true);
@@ -282,6 +148,7 @@
         // App 鍚嶇О鏈湴鍖�
         _rootDict.SetBoolean("Application has localized display name", true);
         _rootDict.SetString("CFBundleDevelopmentRegion", "english");
+        _rootDict.SetString("Localization native development region", "english");
 
         PlistElementArray nsURLTypes = _rootDict.CreateArray("CFBundleURLTypes");
         var dict0 = nsURLTypes.AddDict();
@@ -321,7 +188,7 @@
 
         // fimpfunSDK 鐢熷懡鍛ㄦ湡
         _xclass.WriteBelow("- (BOOL)application:(UIApplication*)app openURL:(NSURL*)url options:(NSDictionary<NSString*, id>*)options\n{", "\n    [_fimpfunBridge application:app openURL:url options:options];");
-        _xclass.WriteBelow("- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation\n{", "\n    return [_fimpfunBridge application:application openURL:url sourceApplication:sourceApplication annotation:annotation];");
+
         _xclass.WriteBelow("::printf(\"-> applicationDidBecomeActive()\\n\");", "[_fimpfunBridge applicationDidBecomeActive:application];");
 
 
@@ -333,9 +200,18 @@
                            "@property (readonly, copy, nonatomic) FimpfunBridge*  fimpfunBridge;");
 
         // 3.1 閫傞厤娆х洘鏀跨瓥锛氬湪 viewDidAppear 涓皟鐢� adaptingEUGDPR锛堟枃妗h姹傦級
-        var _viewController = new XClass(projectPath + "/Classes/UnityViewControllerBase.mm");
-        _viewController.WriteBelow("@implementation UnityViewControllerBase",
-            "\n- (void)viewDidAppear:(BOOL)animated {\n    [super viewDidAppear:animated];\n    [GetAppController().fimpfunBridge viewDidAppear];\n}\n");
+        // UnityViewControllerBase.mm 鍦ㄨ緝鏂� Unity 鐗堟湰锛堝 2022.3+锛変腑鍙兘涓嶅瓨鍦�
+        string viewControllerPath = projectPath + "/Classes/UnityViewControllerBase.mm";
+        if (System.IO.File.Exists(viewControllerPath))
+        {
+            var _viewController = new XClass(viewControllerPath);
+            _viewController.WriteBelow("@implementation UnityViewControllerBase",
+                "\n- (void)viewDidAppear:(BOOL)animated {\n    [super viewDidAppear:animated];\n    [GetAppController().fimpfunBridge viewDidAppear];\n}\n");
+        }
+        else
+        {
+            Debug.LogWarning("[XCodeProjectMod] UnityViewControllerBase.mm 鏂囦欢涓嶅瓨鍦紝璺宠繃 viewDidAppear 娉ㄥ叆銆傛 Unity 鐗堟湰鍙兘宸茬Щ闄よ鏂囦欢銆�");
+        }
 
         // 鍒涘缓 InfoPlist.strings锛圓pp 鍚嶇О鏈湴鍖栵級
         CreateInfoPlistStrings(projectPath);
@@ -346,31 +222,57 @@
     /// </summary>
     private static void CreateInfoPlistStrings(string projectPath)
     {
-        string stringsDir = projectPath + "/English.lproj";
-        if (!Directory.Exists(stringsDir))
+        // 鑻辨枃锛堥粯璁わ級
+        string enDir = projectPath + "/English.lproj";
+        if (!Directory.Exists(enDir))
         {
-            Directory.CreateDirectory(stringsDir);
+            Directory.CreateDirectory(enDir);
         }
-        string stringsPath = stringsDir + "/InfoPlist.strings";
-        if (!File.Exists(stringsPath))
+        string enStringsPath = enDir + "/InfoPlist.strings";
+        if (!File.Exists(enStringsPath))
         {
-            File.WriteAllText(stringsPath, "CFBundleDisplayName = \"Legend of the Sword Master\";\n");
+            File.WriteAllText(enStringsPath, "CFBundleDisplayName = \"EZ PZ\";\n");
+        }
+
+        // 涓枃
+        string zhDir = projectPath + "/zh-Hans.lproj";
+        if (!Directory.Exists(zhDir))
+        {
+            Directory.CreateDirectory(zhDir);
+        }
+        string zhStringsPath = zhDir + "/InfoPlist.strings";
+        if (!File.Exists(zhStringsPath))
+        {
+            File.WriteAllText(zhStringsPath, "CFBundleDisplayName = \"鎳掍汉涓夊浗\";\n");
         }
 
         // 灏� InfoPlist.strings 娣诲姞鍒� Xcode 宸ョ▼
         string _projectPath = PBXProject.GetPBXProjectPath(projectPath);
-        PBXProject project = new PBXProject();
-        project.ReadFromString(File.ReadAllText(_projectPath));
-        string targetGUID = project.TargetGuidByName(PBXProject.GetUnityTargetName());
+        try
+        {
+            PBXProject project = new PBXProject();
+            project.ReadFromString(File.ReadAllText(_projectPath));
+            string targetGUID = project.TargetGuidByName(PBXProject.GetUnityTargetName());
 
-        string relPath = "English.lproj/InfoPlist.strings";
-        string fileGuid = project.AddFile(relPath, relPath, PBXSourceTree.Source);
-        project.AddFileToBuild(targetGUID, fileGuid);
+            // 鑻辨枃
+            string enRelPath = "English.lproj/InfoPlist.strings";
+            string enFileGuid = project.AddFile(enRelPath, enRelPath, PBXSourceTree.Source);
+            project.AddFileToBuild(targetGUID, enFileGuid);
 
-        // 娣诲姞 Sign In with Apple entitlements
-        AddEntitlements(projectPath, project, targetGUID);
+            // 涓枃
+            string zhRelPath = "zh-Hans.lproj/InfoPlist.strings";
+            string zhFileGuid = project.AddFile(zhRelPath, zhRelPath, PBXSourceTree.Source);
+            project.AddFileToBuild(targetGUID, zhFileGuid);
 
-        File.WriteAllText(_projectPath, project.WriteToString());
+            // 娣诲姞 Sign In with Apple entitlements
+            AddEntitlements(projectPath, project, targetGUID);
+
+            File.WriteAllText(_projectPath, project.WriteToString());
+        }
+        catch (System.Exception e)
+        {
+            Debug.LogError("[XCodeProjectMod] 灏� InfoPlist.strings 娣诲姞鍒� Xcode 宸ョ▼澶辫触: " + e.Message);
+        }
     }
 
     /// <summary>
@@ -411,14 +313,11 @@
             }
         }
 
-        // 灏� entitlements 鏂囦欢鍔犲叆宸ョ▼骞惰缃� build property
+        // 璁剧疆 CODE_SIGN_ENTITLEMENTS build property锛堜笉鍔犲叆 Copy Bundle Resources锛�
+        // entitlements 鏂囦欢鍙渶瑕佸湪 Build Settings 涓紩鐢紝涓嶉渶瑕佸姞鍏ヤ换浣� Build Phase
         string entFileName = PBXProject.GetUnityTargetName() + ".entitlements";
-        string fileGuid = project.AddFile(entFileName, entFileName, PBXSourceTree.Source);
-        project.AddFileToBuild(targetGUID, fileGuid);
         project.SetBuildProperty(targetGUID, "CODE_SIGN_ENTITLEMENTS", entFileName);
     }
-
-    
 
     private static string GetBuildPath()
     {
@@ -448,6 +347,21 @@
             }
         }
         return _sceneNames.ToArray();
+    }
+
+    private static void CopyDirectory(string sourceDir, string destDir)
+    {
+        Directory.CreateDirectory(destDir);
+        foreach (var file in Directory.GetFiles(sourceDir))
+        {
+            string destFile = Path.Combine(destDir, Path.GetFileName(file));
+            File.Copy(file, destFile, true);
+        }
+        foreach (var dir in Directory.GetDirectories(sourceDir))
+        {
+            string destSubDir = Path.Combine(destDir, Path.GetFileName(dir));
+            CopyDirectory(dir, destSubDir);
+        }
     }
 
     private static bool s_IsAppend = false;
@@ -487,5 +401,4 @@
         p.Start();
         p.WaitForExit();
     }
-
 }

--
Gitblit v1.8.0