fix:更换sdk,修复bug
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using System.IO;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
|
||||
public static class FixUnityiOSDuplicateResources
|
||||
{
|
||||
[PostProcessBuild(9999)]
|
||||
public static void OnPostProcessBuild(BuildTarget target, string path)
|
||||
{
|
||||
if (target != BuildTarget.iOS) return;
|
||||
|
||||
// ✅ 正确路径(修复完毕)
|
||||
string projPath = Path.Combine(path, "Unity-iPhone.xcodeproj", "project.pbxproj");
|
||||
|
||||
PBXProject proj = new PBXProject();
|
||||
proj.ReadFromFile(projPath);
|
||||
|
||||
string mainTarget = proj.GetUnityMainTargetGuid();
|
||||
|
||||
// 移除重复资源,解决 Multiple commands produce 报错
|
||||
RemoveFile(proj, mainTarget, "PAGAdSDK.bundle");
|
||||
RemoveFile(proj, mainTarget, "AppLovinSDK.bundle");
|
||||
RemoveFile(proj, mainTarget, "BigoADS.bundle");
|
||||
RemoveFile(proj, mainTarget, "InMobiSDK.bundle");
|
||||
|
||||
File.WriteAllText(projPath, proj.WriteToString());
|
||||
Debug.Log("✅ 自动修复 iOS 重复资源冲突成功!");
|
||||
}
|
||||
|
||||
private static void RemoveFile(PBXProject proj, string targetGuid, string filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
string guid = proj.FindFileGuidByProjectPath(filename);
|
||||
if (!string.IsNullOrEmpty(guid))
|
||||
{
|
||||
proj.RemoveFileFromBuild(targetGuid, guid);
|
||||
proj.RemoveFile(guid);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user