From 82c997068d9028cd9aea126c80716d22d596a251 Mon Sep 17 00:00:00 2001 From: yuqucheng <> Date: Mon, 6 Jul 2026 15:42:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0iOS=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E3=80=81Firebase=E4=BE=9D=E8=B5=96=E5=8F=8A?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 优化 iOS 重复 Shell 脚本修复逻辑 - 添加 Firebase Analytics 依赖 - 重命名图标资源为 Icon-iPhone 标准格式 --- Assets/Editor/iOSFixDuplicateShellScript.cs | 67 ++++++++++++++++-- .../Firebase/Editor/AnalyticsDependencies.xml | 2 + Assets/Texture/1024.png.meta | 16 ++--- Assets/Texture/80.png.meta | 10 +-- Assets/Texture/87.png.meta | 10 +-- .../Texture/{120.png => Icon-iPhone-120.png} | Bin ...{120.png.meta => Icon-iPhone-120.png.meta} | 2 +- .../Texture/{180.png => Icon-iPhone-180.png} | Bin ...{180.png.meta => Icon-iPhone-180.png.meta} | 2 +- ProjectSettings/ProjectSettings.asset | 2 +- 10 files changed, 84 insertions(+), 27 deletions(-) rename Assets/Texture/{120.png => Icon-iPhone-120.png} (100%) rename Assets/Texture/{120.png.meta => Icon-iPhone-120.png.meta} (98%) rename Assets/Texture/{180.png => Icon-iPhone-180.png} (100%) rename Assets/Texture/{180.png.meta => Icon-iPhone-180.png.meta} (98%) diff --git a/Assets/Editor/iOSFixDuplicateShellScript.cs b/Assets/Editor/iOSFixDuplicateShellScript.cs index 470c63c..ae3f5b2 100644 --- a/Assets/Editor/iOSFixDuplicateShellScript.cs +++ b/Assets/Editor/iOSFixDuplicateShellScript.cs @@ -3,24 +3,79 @@ using UnityEditor; using UnityEditor.Callbacks; using System.IO; using System.Text.RegularExpressions; +using UnityEngine; public class iOSFixDuplicateShellScript { - [PostProcessBuild] + [PostProcessBuild(999)] public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject) { if (target != BuildTarget.iOS) return; + FixDuplicateShellScript(pathToBuiltProject); + FixPodfile(pathToBuiltProject); + } + + private static void FixDuplicateShellScript(string pathToBuiltProject) + { string projPath = Path.Combine(pathToBuiltProject, "Unity-iPhone.xcodeproj/project.pbxproj"); - if (!File.Exists(projPath)) return; + if (!File.Exists(projPath)) + { + Debug.LogWarning("[FixDupShellScript] pbxproj not found: " + projPath); + return; + } string content = File.ReadAllText(projPath); - // 匹配 GameAssembly target 的 buildPhases 中连续两个相同的 ShellScript - string pattern = @"(\t+([A-F0-9]+) /\* ShellScript \*/,)\n\t+\2 /\* ShellScript \*,/"; - content = Regex.Replace(content, pattern, "$1"); + string pattern = @"(\t+([A-F0-9]+) /\* ShellScript \*/,)\r?\n\t+\2 /\* ShellScript \*,/"; + string newContent = Regex.Replace(content, pattern, "$1"); + + if (newContent != content) + { + File.WriteAllText(projPath, newContent); + Debug.Log("[FixDupShellScript] Removed duplicate ShellScript from GameAssembly target"); + } + else + { + Debug.Log("[FixDupShellScript] No duplicate ShellScript found"); + } + } - File.WriteAllText(projPath, content); + private static void FixPodfile(string pathToBuiltProject) + { + string podfilePath = Path.Combine(pathToBuiltProject, "Podfile"); + if (!File.Exists(podfilePath)) + { + Debug.LogWarning("[FixPodfile] Podfile not found"); + return; + } + + string content = File.ReadAllText(podfilePath); + bool modified = false; + + // 移除不需要的 Firebase/Analytics + if (content.Contains("Firebase/Analytics")) + { + content = Regex.Replace(content, @"\s*pod\s+'Firebase/Analytics'[^\n]*\n?", "\n"); + modified = true; + } + + // 将 12.4.0 统一为 12.14.0 + if (content.Contains("12.4.0")) + { + content = content.Replace("12.4.0", "12.14.0"); + modified = true; + } + + if (modified) + { + File.WriteAllText(podfilePath, content); + Debug.Log("[FixPodfile] Cleaned up Podfile"); + } + else + { + Debug.Log("[FixPodfile] Podfile already clean"); + } } } #endif diff --git a/Assets/Firebase/Editor/AnalyticsDependencies.xml b/Assets/Firebase/Editor/AnalyticsDependencies.xml index c510ce0..ff55aac 100644 --- a/Assets/Firebase/Editor/AnalyticsDependencies.xml +++ b/Assets/Firebase/Editor/AnalyticsDependencies.xml @@ -5,6 +5,8 @@ FirebaseAnalytics iOS and Android Dependencies. + + diff --git a/Assets/Texture/1024.png.meta b/Assets/Texture/1024.png.meta index 84ef3c9..45e17e8 100644 --- a/Assets/Texture/1024.png.meta +++ b/Assets/Texture/1024.png.meta @@ -6,7 +6,7 @@ TextureImporter: serializedVersion: 13 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,13 +37,13 @@ TextureImporter: filterMode: 1 aniso: 1 mipBias: 0 - wrapU: 0 - wrapV: 0 + wrapU: 1 + wrapV: 1 wrapW: 0 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 - spriteMode: 0 + spriteMode: 1 spriteExtrude: 1 spriteMeshType: 1 alignment: 0 @@ -52,9 +52,9 @@ TextureImporter: spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 - alphaIsTransparency: 0 + alphaIsTransparency: 1 spriteTessellationDetail: -1 - textureType: 0 + textureType: 8 textureShape: 1 singleChannelComponent: 0 flipbookRows: 1 @@ -125,7 +125,7 @@ TextureImporter: outline: [] physicsShape: [] bones: [] - spriteID: + spriteID: 5e97eb03825dee720800000000000000 internalID: 0 vertices: [] indices: diff --git a/Assets/Texture/80.png.meta b/Assets/Texture/80.png.meta index 0fd7c89..28d57f7 100644 --- a/Assets/Texture/80.png.meta +++ b/Assets/Texture/80.png.meta @@ -40,10 +40,10 @@ TextureImporter: wrapU: 0 wrapV: 0 wrapW: 0 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 - spriteMode: 0 + spriteMode: 1 spriteExtrude: 1 spriteMeshType: 1 alignment: 0 @@ -97,12 +97,12 @@ TextureImporter: buildTarget: iPhone maxTextureSize: 2048 resizeAlgorithm: 0 - textureFormat: -1 + textureFormat: 50 textureCompression: 1 compressionQuality: 50 crunchedCompression: 0 allowsAlphaSplitting: 0 - overridden: 0 + overridden: 1 ignorePlatformSupport: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 @@ -125,7 +125,7 @@ TextureImporter: outline: [] physicsShape: [] bones: [] - spriteID: + spriteID: 5e97eb03825dee720800000000000000 internalID: 0 vertices: [] indices: diff --git a/Assets/Texture/87.png.meta b/Assets/Texture/87.png.meta index 0deac9e..4307304 100644 --- a/Assets/Texture/87.png.meta +++ b/Assets/Texture/87.png.meta @@ -40,10 +40,10 @@ TextureImporter: wrapU: 0 wrapV: 0 wrapW: 0 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 - spriteMode: 0 + spriteMode: 1 spriteExtrude: 1 spriteMeshType: 1 alignment: 0 @@ -97,12 +97,12 @@ TextureImporter: buildTarget: iPhone maxTextureSize: 2048 resizeAlgorithm: 0 - textureFormat: -1 + textureFormat: 50 textureCompression: 1 compressionQuality: 50 crunchedCompression: 0 allowsAlphaSplitting: 0 - overridden: 0 + overridden: 1 ignorePlatformSupport: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 @@ -125,7 +125,7 @@ TextureImporter: outline: [] physicsShape: [] bones: [] - spriteID: + spriteID: 5e97eb03825dee720800000000000000 internalID: 0 vertices: [] indices: diff --git a/Assets/Texture/120.png b/Assets/Texture/Icon-iPhone-120.png similarity index 100% rename from Assets/Texture/120.png rename to Assets/Texture/Icon-iPhone-120.png diff --git a/Assets/Texture/120.png.meta b/Assets/Texture/Icon-iPhone-120.png.meta similarity index 98% rename from Assets/Texture/120.png.meta rename to Assets/Texture/Icon-iPhone-120.png.meta index c63a539..1cb6443 100644 --- a/Assets/Texture/120.png.meta +++ b/Assets/Texture/Icon-iPhone-120.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d89f75d2829914aefabc2c12ee61e74d +guid: 2fe29f66f37c34d5ca39cf642d8a2ba3 TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Assets/Texture/180.png b/Assets/Texture/Icon-iPhone-180.png similarity index 100% rename from Assets/Texture/180.png rename to Assets/Texture/Icon-iPhone-180.png diff --git a/Assets/Texture/180.png.meta b/Assets/Texture/Icon-iPhone-180.png.meta similarity index 98% rename from Assets/Texture/180.png.meta rename to Assets/Texture/Icon-iPhone-180.png.meta index f5d6166..bea919b 100644 --- a/Assets/Texture/180.png.meta +++ b/Assets/Texture/Icon-iPhone-180.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 72592ba5df3304ad8a664eb6c0ab04da +guid: 29fdb52e7fc6c411891c323b5d5b6f01 TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 5068649..5d2522f 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -174,7 +174,7 @@ PlayerSettings: buildNumber: Standalone: 0 VisionOS: 0 - iPhone: 0 + iPhone: 2 tvOS: 0 overrideDefaultApplicationIdentifier: 1 AndroidBundleVersionCode: 1