From 784bc7c0ee54740b739924ac8c37ec547dff7996 Mon Sep 17 00:00:00 2001 From: CORE-FOLDCCCore <1813547935@qq.com> Date: Wed, 1 Jul 2026 18:09:08 +0800 Subject: [PATCH] release: 1.4.17 --- .../Script/Editor/ATPostProcessBuildiOS.cs | 2 + CHANGELOG.md | 10 + Samples~/IAAAdDebugSample/README.md | 14 +- .../Editor/ToponBuildSettingsStore.cs | 223 +++++++++++++++++- .../Editor/ToponBuildWindowExtension.cs | 58 ++++- package.json | 2 +- 6 files changed, 298 insertions(+), 11 deletions(-) diff --git a/AnyThinkPlugin/Script/Editor/ATPostProcessBuildiOS.cs b/AnyThinkPlugin/Script/Editor/ATPostProcessBuildiOS.cs index a8e2a3a..c3341aa 100644 --- a/AnyThinkPlugin/Script/Editor/ATPostProcessBuildiOS.cs +++ b/AnyThinkPlugin/Script/Editor/ATPostProcessBuildiOS.cs @@ -44,6 +44,8 @@ namespace AnyThink.Scripts.Editor get { var dynamicLibraryPathsToEmbed = new List(); + dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "AnyThinkiOS/core/AnyThinkSDK.xcframework")); + dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "SmartdigimktCNSDK/KuYingSDK/SmartdigimktSDK.xcframework")); dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "KSAdSDK/KSAdSDK.xcframework")); dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "StartAppSDK/StartApp.xcframework")); dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "BigoADS/BigoADS/BigoADS.xcframework")); diff --git a/CHANGELOG.md b/CHANGELOG.md index 7548d89..2734741 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# [1.4.17] + +### 修复 + +* iOS 导出后处理会把 `AnyThinkSDK.xcframework` 和 `SmartdigimktSDK.xcframework` 加入主 App target 的 Embed Frameworks,避免真机启动时 `UnityFramework.framework` 因缺少动态依赖而加载失败并直接退出。 + +### 新增 + +* `TopOn 配置` 页签新增 iOS DebugUI Pod 开关,测试包可按需写入 `AnyThinkDebugUISDK 1.0.7`,正式包默认不带调试工具。 + # [1.4.16] ### 新增 diff --git a/Samples~/IAAAdDebugSample/README.md b/Samples~/IAAAdDebugSample/README.md index 98207b8..0338367 100644 --- a/Samples~/IAAAdDebugSample/README.md +++ b/Samples~/IAAAdDebugSample/README.md @@ -16,7 +16,18 @@ - `BaseAwardAdKeyValue.value` = 激励视频广告位ID - `BaseInteractionAdKeyValue.value` = 插屏广告位ID 3. 打开示例场景 `IAAAdDebugSample.unity` -4. 运行到 Android 手机测试 +4. 运行到 Android 或 iOS 真机测试 + +## iOS DebugUI 启用 + +1. 在 `Build/Modular Build System` 的 `TopOn 配置` 页签开启 `启用 iOS DebugUI Pod` +2. iOS DebugUI 版本保持默认 `1.0.7` +3. 导出 Xcode 工程后执行 `pod install --repo-update` +4. 在 Taku 后台获取 `SDK Debug Key` +5. 在示例配置 `CommonKeyValues` 中设置 `topon.debugger_key=` +6. 真机首次请求 IDFA 时选择允许 +7. 点击 `Initialize ADManager` +8. 点击 `Open DebugUI` ## 当前默认策略 @@ -57,6 +68,7 @@ - `topon.debug=true` 只用于打开 SDK 调试日志 - 不会再因为 debug 模式自动弹出官方 DebugUI - 官方 DebugUI 改为手动点击 `Open DebugUI` +- iOS 需要构建期启用 `AnyThinkDebugUISDK` Pod,并配置 `topon.debugger_key` ## 场景到达测试方式 diff --git a/Topon_Adapter/Editor/ToponBuildSettingsStore.cs b/Topon_Adapter/Editor/ToponBuildSettingsStore.cs index 66b9efb..2994cbc 100644 --- a/Topon_Adapter/Editor/ToponBuildSettingsStore.cs +++ b/Topon_Adapter/Editor/ToponBuildSettingsStore.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; using System.IO; +using System.Text.RegularExpressions; using UnityEditor; +using UnityEditor.Callbacks; using UnityEngine; namespace Topon_Adapter.Editor @@ -13,11 +15,15 @@ namespace Topon_Adapter.Editor public bool forceVerbtoUtilVersion = true; public string verbtoUtilDependency = ToponBuildSettingsStore.DefaultVerbtoUtilDependency; public bool stripResolvedDebuggerArtifacts = true; + public bool enableIOSDebuggerUI = false; + public string iosDebuggerPodVersion = ToponBuildSettingsStore.DefaultIOSDebuggerPodVersion; } internal static class ToponBuildSettingsStore { public const string DefaultVerbtoUtilDependency = "com.verbto.tools:util:1.1.3"; + public const string IOSDebuggerPodName = "AnyThinkDebugUISDK"; + public const string DefaultIOSDebuggerPodVersion = "1.0.7"; private const string ActiveBuildSessionKey = "Commercialization.Topon.ActiveBuildSettings"; private const string SettingsFileSuffix = "_topon_build_settings.json"; @@ -47,6 +53,16 @@ namespace Topon_Adapter.Editor return settings.verbtoUtilDependency.Trim(); } + public static string GetIOSDebuggerPodVersion(ToponBuildSettings settings) + { + if (settings == null || string.IsNullOrWhiteSpace(settings.iosDebuggerPodVersion)) + { + return DefaultIOSDebuggerPodVersion; + } + + return settings.iosDebuggerPodVersion.Trim(); + } + public static ToponBuildSettings LoadForProfileName(string profileName, string repositoryRoot) { var settings = CreateDefault(); @@ -298,7 +314,9 @@ namespace Topon_Adapter.Editor enableDebuggerUI = settings.enableDebuggerUI, forceVerbtoUtilVersion = settings.forceVerbtoUtilVersion, verbtoUtilDependency = GetVerbtoUtilDependency(settings), - stripResolvedDebuggerArtifacts = settings.stripResolvedDebuggerArtifacts + stripResolvedDebuggerArtifacts = settings.stripResolvedDebuggerArtifacts, + enableIOSDebuggerUI = settings.enableIOSDebuggerUI, + iosDebuggerPodVersion = GetIOSDebuggerPodVersion(settings) }; } @@ -310,6 +328,7 @@ namespace Topon_Adapter.Editor } settings.verbtoUtilDependency = NormalizeDependency(settings.verbtoUtilDependency); + settings.iosDebuggerPodVersion = NormalizeIOSDebuggerPodVersion(settings.iosDebuggerPodVersion); } private static string NormalizeDependency(string dependency) @@ -322,6 +341,16 @@ namespace Topon_Adapter.Editor return dependency.Trim(); } + private static string NormalizeIOSDebuggerPodVersion(string version) + { + if (string.IsNullOrWhiteSpace(version)) + { + return DefaultIOSDebuggerPodVersion; + } + + return version.Trim(); + } + private static string GetVersionFromDependency(string dependency) { dependency = NormalizeDependency(dependency); @@ -386,4 +415,196 @@ namespace Topon_Adapter.Editor return new string(chars); } } + +#if UNITY_IOS || UNITY_IPHONE + internal static class ToponIOSDebuggerDependencyPostProcessor + { + private const string Tag = "[TopOn Build]"; + + [PostProcessBuild(int.MaxValue)] + public static void OnPostProcessBuild(BuildTarget buildTarget, string buildPath) + { + if (buildTarget != BuildTarget.iOS) + { + return; + } + + var settings = ToponBuildSettingsStore.GetActiveForCurrentBuild(); + try + { + ProcessExportedProject(buildPath, settings); + } + finally + { + ToponBuildSettingsStore.ClearActiveBuildSettings(); + } + } + + public static void ProcessExportedProject(string buildPath, ToponBuildSettings settings) + { + if (settings == null) + { + settings = ToponBuildSettingsStore.CreateDefault(); + } + + var podfilePath = Path.Combine(buildPath, "Podfile"); + if (!File.Exists(podfilePath)) + { + if (settings.enableIOSDebuggerUI) + { + Debug.LogWarning($"{Tag} Podfile not found, cannot add {ToponBuildSettingsStore.IOSDebuggerPodName}: {podfilePath}"); + } + + return; + } + + var content = File.ReadAllText(podfilePath); + var updated = RewritePodfile(content, settings); + if (!string.Equals(content, updated, StringComparison.Ordinal)) + { + File.WriteAllText(podfilePath, updated); + } + + if (settings.enableIOSDebuggerUI) + { + Debug.Log($"{Tag} iOS DebugUI pod enabled: {ToponBuildSettingsStore.IOSDebuggerPodName} {ToponBuildSettingsStore.GetIOSDebuggerPodVersion(settings)}."); + } + else + { + Debug.Log($"{Tag} iOS DebugUI pod disabled for this build."); + } + } + + private static string RewritePodfile(string content, ToponBuildSettings settings) + { + var newline = content.Contains("\r\n") ? "\r\n" : "\n"; + var lines = new List(content.Replace("\r\n", "\n").Replace('\r', '\n').Split('\n')); + + for (var i = lines.Count - 1; i >= 0; i--) + { + if (IsDebuggerPodLine(lines[i])) + { + lines.RemoveAt(i); + } + } + + if (settings.enableIOSDebuggerUI) + { + InsertDebuggerPod(lines, ToponBuildSettingsStore.GetIOSDebuggerPodVersion(settings)); + } + + return string.Join(newline, lines); + } + + private static bool IsDebuggerPodLine(string line) + { + return Regex.IsMatch(line ?? string.Empty, + @"^\s*pod\s+['""]" + ToponBuildSettingsStore.IOSDebuggerPodName + @"['""]", + RegexOptions.CultureInvariant); + } + + private static void InsertDebuggerPod(List lines, string version) + { + var targetRange = FindTargetRange(lines, "UnityFramework"); + if (targetRange.start < 0) + { + targetRange = FindTargetRange(lines, "Unity-iPhone"); + } + + if (targetRange.start >= 0) + { + var indent = ResolvePodIndent(lines, targetRange); + var podLine = $"{indent}pod '{ToponBuildSettingsStore.IOSDebuggerPodName}', '{version}'"; + lines.Insert(ResolvePodInsertIndex(lines, targetRange), podLine); + return; + } + + if (lines.Count > 0 && !string.IsNullOrWhiteSpace(lines[lines.Count - 1])) + { + lines.Add(string.Empty); + } + + lines.Add("target 'UnityFramework' do"); + lines.Add($" pod '{ToponBuildSettingsStore.IOSDebuggerPodName}', '{version}'"); + lines.Add("end"); + } + + private static (int start, int end) FindTargetRange(List lines, string targetName) + { + var targetPattern = new Regex(@"^\s*target\s+['""]" + Regex.Escape(targetName) + @"['""]\s+do\b", + RegexOptions.CultureInvariant); + + for (var i = 0; i < lines.Count; i++) + { + if (!targetPattern.IsMatch(lines[i] ?? string.Empty)) + { + continue; + } + + var depth = 0; + for (var j = i; j < lines.Count; j++) + { + var line = StripComment(lines[j]); + if (Regex.IsMatch(line, @"\bdo\b", RegexOptions.CultureInvariant)) + { + depth++; + } + + if (Regex.IsMatch(line, @"^\s*end\s*$", RegexOptions.CultureInvariant)) + { + depth--; + if (depth <= 0) + { + return (i, j); + } + } + } + + return (i, lines.Count); + } + + return (-1, -1); + } + + private static int ResolvePodInsertIndex(List lines, (int start, int end) targetRange) + { + var insertIndex = targetRange.start + 1; + for (var i = targetRange.start + 1; i < targetRange.end && i < lines.Count; i++) + { + if (Regex.IsMatch(lines[i] ?? string.Empty, @"^\s*pod\s+", RegexOptions.CultureInvariant)) + { + insertIndex = i + 1; + } + } + + return insertIndex; + } + + private static string ResolvePodIndent(List lines, (int start, int end) targetRange) + { + for (var i = targetRange.start + 1; i < targetRange.end && i < lines.Count; i++) + { + var match = Regex.Match(lines[i] ?? string.Empty, @"^(\s*)pod\s+", RegexOptions.CultureInvariant); + if (match.Success) + { + return match.Groups[1].Value; + } + } + + var targetIndent = Regex.Match(lines[targetRange.start] ?? string.Empty, @"^(\s*)", RegexOptions.CultureInvariant).Value; + return targetIndent + " "; + } + + private static string StripComment(string line) + { + if (string.IsNullOrEmpty(line)) + { + return string.Empty; + } + + var commentIndex = line.IndexOf('#'); + return commentIndex >= 0 ? line.Substring(0, commentIndex) : line; + } + } +#endif } diff --git a/Topon_Adapter/Editor/ToponBuildWindowExtension.cs b/Topon_Adapter/Editor/ToponBuildWindowExtension.cs index cceb84c..c45ad7d 100644 --- a/Topon_Adapter/Editor/ToponBuildWindowExtension.cs +++ b/Topon_Adapter/Editor/ToponBuildWindowExtension.cs @@ -32,12 +32,12 @@ namespace Topon_Adapter.Editor EditorGUILayout.LabelField("TopOn Android 调试工具", EditorStyles.boldLabel); EditorGUILayout.HelpBox( - "正式 release 默认关闭 DebugUI。verbto util 独立控制,默认强制指定到 1.1.3,避免回落到存在数据库降级风险的旧版本。", + "Android 正式 release 默认关闭 DebugUI。verbto util 独立控制,默认强制指定到 1.1.3,避免回落到存在数据库降级风险的旧版本。", MessageType.Info); EditorGUI.BeginChangeCheck(); settings.enableDebuggerUI = EditorGUILayout.Toggle( - new GUIContent("启用 DebugUI 依赖", "仅用于开发/测试包;正式 release 应保持关闭。"), + new GUIContent("启用 Android DebugUI 依赖", "仅用于开发/测试包;正式 release 应保持关闭。"), settings.enableDebuggerUI); settings.forceVerbtoUtilVersion = EditorGUILayout.Toggle( @@ -55,6 +55,23 @@ namespace Topon_Adapter.Editor new GUIContent("禁用时剔除 DebugUI 旧产物", "关闭 DebugUI 时,从生成的 Gradle 工程中删除旧 Resolver 带入的 debugger-ui AAR;不会把 verbto util 当作 DebugUI 一起剔除。"), settings.stripResolvedDebuggerArtifacts); + EditorGUILayout.Space(6); + EditorGUILayout.LabelField("TopOn iOS 调试工具", EditorStyles.boldLabel); + EditorGUILayout.HelpBox( + "iOS DebugUI 通过导出后的 Podfile 写入 AnyThinkDebugUISDK。当前 Taku iOS SDK 6.5.45 对应 DebugUI 1.0.7;正式 release 应保持关闭。", + MessageType.Info); + + settings.enableIOSDebuggerUI = EditorGUILayout.Toggle( + new GUIContent("启用 iOS DebugUI Pod", "仅用于开发/测试包;启用后导出工程 Podfile 会写入 AnyThinkDebugUISDK。"), + settings.enableIOSDebuggerUI); + + using (new EditorGUI.DisabledScope(!settings.enableIOSDebuggerUI)) + { + settings.iosDebuggerPodVersion = EditorGUILayout.TextField( + new GUIContent("iOS DebugUI 版本", "Taku iOS SDK 6.5.45 推荐 AnyThinkDebugUISDK 1.0.7。"), + ToponBuildSettingsStore.GetIOSDebuggerPodVersion(settings)); + } + if (EditorGUI.EndChangeCheck()) { ToponBuildSettingsStore.SaveForProfileName(profile.profileName, context.repositoryRoot, settings); @@ -63,11 +80,20 @@ namespace Topon_Adapter.Editor EditorGUILayout.Space(6); if (settings.enableDebuggerUI) { - EditorGUILayout.HelpBox("当前配置会把 TopOn DebugUI 打进 Android 构建;请不要用于正式 release。", MessageType.Warning); + EditorGUILayout.HelpBox("当前配置会把 TopOn Android DebugUI 打进 Android 构建;请不要用于正式 release。", MessageType.Warning); } else { - EditorGUILayout.HelpBox("当前配置不会打包 TopOn DebugUI。", MessageType.None); + EditorGUILayout.HelpBox("当前配置不会打包 TopOn Android DebugUI。", MessageType.None); + } + + if (settings.enableIOSDebuggerUI) + { + EditorGUILayout.HelpBox($"当前配置会在 iOS Podfile 写入 {ToponBuildSettingsStore.IOSDebuggerPodName} {ToponBuildSettingsStore.GetIOSDebuggerPodVersion(settings)};请不要用于正式 release。", MessageType.Warning); + } + else + { + EditorGUILayout.HelpBox("当前配置不会打包 TopOn iOS DebugUI。", MessageType.None); } if (settings.forceVerbtoUtilVersion) @@ -96,15 +122,28 @@ namespace Topon_Adapter.Editor var report = BuildWindowExtensionReport.Pass(); if (settings.enableDebuggerUI) { - report.AddMessage("TopOn DebugUI 已启用。"); + report.AddMessage("TopOn Android DebugUI 已启用。"); if (!profile.isDevelopment) { - report.AddWarning("当前不是 Development Build,请确认该配置不是正式 release。"); + report.AddWarning("Android DebugUI 已启用,但当前不是 Development Build,请确认该配置不是正式 release。"); } } else { - report.AddMessage("TopOn DebugUI 已关闭,构建产物不会打包 debugger-ui。"); + report.AddMessage("TopOn Android DebugUI 已关闭,构建产物不会打包 debugger-ui。"); + } + + if (settings.enableIOSDebuggerUI) + { + report.AddMessage($"TopOn iOS DebugUI 已启用,将写入 {ToponBuildSettingsStore.IOSDebuggerPodName} {ToponBuildSettingsStore.GetIOSDebuggerPodVersion(settings)}。"); + if (!profile.isDevelopment) + { + report.AddWarning("iOS DebugUI 已启用,但当前不是 Development Build,请确认该配置不是正式 release。"); + } + } + else + { + report.AddMessage("TopOn iOS DebugUI 已关闭,导出工程不会写入 AnyThinkDebugUISDK。"); } if (!settings.enableDebuggerUI && ToponBuildSettingsStore.HasStaleDebuggerResolverOutput(context.repositoryRoot)) @@ -149,9 +188,12 @@ namespace Topon_Adapter.Editor EditorGUILayout.Space(6); EditorGUILayout.LabelField("本地依赖状态", EditorStyles.boldLabel); EditorGUILayout.LabelField("旧 DebugUI 输出", hasStaleDebuggerOutput ? "检测到 debugger-ui" : "未检测到"); - EditorGUILayout.LabelField("DebugUI AAR/JAR", debuggerArtifacts.Count == 0 ? "未检测到" : $"{debuggerArtifacts.Count} 个"); + EditorGUILayout.LabelField("Android DebugUI AAR/JAR", debuggerArtifacts.Count == 0 ? "未检测到" : $"{debuggerArtifacts.Count} 个"); EditorGUILayout.LabelField("verbto util 强制", settings.forceVerbtoUtilVersion ? dependency : "自动/不干预"); EditorGUILayout.LabelField("verbto util 本地产物", utilArtifacts.Count == 0 ? "未检测到" : $"{utilArtifacts.Count} 个"); + EditorGUILayout.LabelField("iOS DebugUI Pod", settings.enableIOSDebuggerUI + ? $"{ToponBuildSettingsStore.IOSDebuggerPodName} {ToponBuildSettingsStore.GetIOSDebuggerPodVersion(settings)}" + : "关闭"); if (settings.forceVerbtoUtilVersion && hasUnforcedUtilOutput) { EditorGUILayout.HelpBox("检测到本地/Resolver 中存在非强制版本的 verbto util;Android Gradle 工程生成后会改写依赖,并清理旧版本本地产物。", MessageType.Warning); diff --git a/package.json b/package.json index 6f32dab..702a6b3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.commercialization.topon", "displayName": "Commercialization.topon", "description": "基于topon的广告sdk封装,依赖基础商业化模块", - "version": "1.4.16", + "version": "1.4.17", "unity": "2021.1", "license": "MIT", "repository": {