feat(integration): 添加 AppLovin SDK 集成管理功能

- 实现 AppLovinIntegrationManagerUtils 版本比较工具类
- 添加 AppLovinPackageManager 处理 UPM 和 Assets 包管理
- 实现 AppLovinPluginMigrationHelper 插件迁移辅助功能
- 添加 AppLovinUpmManifest 管理 UPM 清单文件操作
- 支持 mediation adapter 的版本检测和安装管理
- 实现重复适配器检测和删除功能
This commit is contained in:
2026-01-20 19:01:21 +08:00
parent 4da1b3290e
commit 5b3dfd98c2
76 changed files with 3768 additions and 3668 deletions

View File

@@ -8,6 +8,7 @@
#if UNITY_IOS
using System.Xml.Linq;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
@@ -20,28 +21,77 @@ namespace AppLovinMax.Scripts.IntegrationManager.Editor
AddGoogleCmpDependencyIfNeeded();
}
private const string UmpLegacyDependencyLine = "<iosPod name=\"GoogleUserMessagingPlatform\" version=\"2.1.0\" />";
private const string UmpDependencyLine = "<iosPod name=\"GoogleUserMessagingPlatform\" version=\"~&gt; 2.1\" />";
private const string IosPodsContainerElementString = "iosPods";
private const string ElementNameIosPods = "iosPods";
private const string ElementNameIosPod = "iosPod";
private const string AttributeNameName = "name";
private const string AttributeNameVersion = "version";
private const string UmpDependencyPod = "GoogleUserMessagingPlatform";
private const string UmpDependencyVersion = "~> 2.1";
private static void AddGoogleCmpDependencyIfNeeded()
{
// Remove the legacy fixed UMP version if it exists, we'll add the dependency with a dynamic version below.
TryRemoveStringFromDependencyFile(UmpLegacyDependencyLine, IosPodsContainerElementString);
if (AppLovinInternalSettings.Instance.ConsentFlowEnabled)
{
TryAddStringToDependencyFile(UmpDependencyLine, IosPodsContainerElementString);
var umpDependency = new XElement(ElementNameIosPod,
new XAttribute(AttributeNameName, UmpDependencyPod),
new XAttribute(AttributeNameVersion, UmpDependencyVersion));
var success = AddOrUpdateIosDependency(UmpDependencyPod, umpDependency);
if (!success)
{
MaxSdkLogger.UserWarning("Google CMP will not function. Unable to add GoogleUserMessagingPlatform dependency.");
}
}
else
{
TryRemoveStringFromDependencyFile(UmpDependencyLine, IosPodsContainerElementString);
RemoveIosDependency(UmpDependencyPod);
}
}
/// <summary>
/// Adds or updates an iOS pod in the AppLovin Dependencies.xml file.
/// </summary>
/// <param name="pod">The pod that we are trying to update</param>
/// <param name="newDependency">The new dependency to add if it doesn't exist</param>
/// <returns>Returns true if the file was successfully edited</returns>
private static bool AddOrUpdateIosDependency(string pod, XElement newDependency)
{
var dependenciesFilePath = AppLovinDependenciesFilePath;
var dependenciesDocument = GetAppLovinDependenciesFile(dependenciesFilePath, AppLovinIntegrationManager.IsPluginInPackageManager);
if (dependenciesDocument == null) return false;
AddOrUpdateDependency(dependenciesDocument,
ElementNameIosPods,
ElementNameIosPod,
AttributeNameName,
pod,
newDependency);
return SaveDependenciesFile(dependenciesDocument, dependenciesFilePath);
}
/// <summary>
/// Removed an iOS pod from the AppLovin Dependencies.xml file.
/// </summary>
/// <param name="pod">The pod to remove</param>
private static void RemoveIosDependency(string pod)
{
var dependenciesFilePath = AppLovinDependenciesFilePath;
var dependenciesDocument = GetAppLovinDependenciesFile(dependenciesFilePath);
if (dependenciesDocument == null) return;
var removed = RemoveDependency(dependenciesDocument,
ElementNameIosPods,
ElementNameIosPod,
AttributeNameName,
pod);
if (!removed) return;
SaveDependenciesFile(dependenciesDocument, dependenciesFilePath);
}
public int callbackOrder
{
get { return int.MaxValue; }
get { return CallbackOrder; }
}
}
}