fix: 更新打包管线的注入时机

Signed-off-by: huyufei <yufei.hu@castbox.fm>
hotfix/v1.0.12.2
胡宇飞 2024-05-30 13:49:23 +08:00
parent 7f4beb6e3f
commit aca914ab02
1 changed files with 19 additions and 21 deletions

View File

@ -42,7 +42,7 @@ namespace Guru.Editor
[PostProcessBuild(45)] // MAX POD Process Order [PostProcessBuild(47)] // MAX POD Process Order
public static void PostBuildFixPodDeps(BuildTarget target, string projPath) public static void PostBuildFixPodDeps(BuildTarget target, string projPath)
{ {
if (target != BuildTarget.iOS) return; if (target != BuildTarget.iOS) return;
@ -74,7 +74,7 @@ namespace Guru.Editor
{ {
if (line.Contains(libName)) if (line.Contains(libName))
{ {
lines[i] = FixOneFirebaseLibVersion(line, fixedVersion, minTargetSdk); lines[i] = FixOneFirebaseLibVersion(line, fixedVersion);
isDirty = true; isDirty = true;
} }
} }
@ -84,33 +84,31 @@ namespace Guru.Editor
if (line.Contains(libName)) if (line.Contains(libName))
{ {
needAdded.Remove(libName); needAdded.Remove(libName);
lines[i] = FixOneFirebaseLibVersion(line, fixedVersion, minTargetSdk); lines[i] = FixOneFirebaseLibVersion(line, fixedVersion);
isDirty = true;
}
}
if (needAdded.Count > 0)
{
// pod 'Firebase/DynamicLinks', '10.20.0'
foreach (var libName in needAdded)
{
idx++;
idx = Mathf.Min(idx, lines.Count - 1);
lines.Insert(idx, $"\tpod '{libName}', '{fixedVersion}'");
isDirty = true; isDirty = true;
} }
} }
} }
if (needAdded.Count > 0)
{
// pod 'Firebase/DynamicLinks', '10.20.0'
foreach (var libName in needAdded)
{
idx++;
idx = Mathf.Min(idx, lines.Count - 1);
lines.Insert(idx, $"\tpod '{libName}', '{fixedVersion}'");
isDirty = true;
}
}
if(isDirty) File.WriteAllLines(podfile, lines); if(isDirty) File.WriteAllLines(podfile, lines);
} }
private static string FixOneFirebaseLibVersion(string line, string fixedVersion, string minTargetSdk) private static string FixOneFirebaseLibVersion(string line, string fixedVersion)
{ {
line = line.Replace("version =", "version="); if(!line.Contains("', '") || !line.Contains("pod")) return line;
string fixedLine = ""; string fixedLine = line.Substring(0, line.IndexOf("', '") + 4) + $"{fixedVersion}'";
fixedLine = line.Substring(line.IndexOf("version=") + 9) + $"\"{fixedVersion}\" minTargetSdk=\"{minTargetSdk}\"";
return fixedLine; return fixedLine;
} }
} }