You've already forked CC-Framework.CrashReport
feat: move bugly build settings into crashreport
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using CCFramework.CrashReport.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEngine;
|
||||
@@ -10,7 +11,6 @@ namespace Editor
|
||||
{
|
||||
public static class CrashPostProcessBuildIOS
|
||||
{
|
||||
private const string PodLine = " pod 'Bugly', '~> 2.6'";
|
||||
private const string UnityFrameworkTarget = "target 'UnityFramework' do";
|
||||
|
||||
[PostProcessBuild(980)]
|
||||
@@ -21,13 +21,21 @@ namespace Editor
|
||||
return;
|
||||
}
|
||||
|
||||
EnsureBuglyPod(pathToBuiltProject);
|
||||
CrashReportBuglyProfileSettings settings = CrashReportBuildSettingsStore.GetLastBuildProfileSettings();
|
||||
if (settings == null || !settings.enableIOSPod)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EnsureBuglyPod(pathToBuiltProject, settings.iosPodVersion);
|
||||
}
|
||||
|
||||
private static void EnsureBuglyPod(string pathToBuiltProject)
|
||||
public static void EnsureBuglyPod(string pathToBuiltProject, string podVersion)
|
||||
{
|
||||
string podfilePath = Path.Combine(pathToBuiltProject, "Podfile");
|
||||
string content = File.Exists(podfilePath) ? File.ReadAllText(podfilePath) : string.Empty;
|
||||
string normalizedVersion = string.IsNullOrWhiteSpace(podVersion) ? "~> 2.6" : podVersion.Trim();
|
||||
string podLine = $" pod 'Bugly', '{normalizedVersion}'";
|
||||
|
||||
if (content.Contains("pod 'Bugly'") || content.Contains("pod \"Bugly\""))
|
||||
{
|
||||
@@ -40,12 +48,12 @@ namespace Editor
|
||||
"platform :ios, '9.0'" + Environment.NewLine +
|
||||
Environment.NewLine +
|
||||
UnityFrameworkTarget + Environment.NewLine +
|
||||
PodLine + Environment.NewLine +
|
||||
podLine + Environment.NewLine +
|
||||
"end" + Environment.NewLine);
|
||||
}
|
||||
else if (content.Contains(UnityFrameworkTarget))
|
||||
{
|
||||
content = content.Replace(UnityFrameworkTarget, UnityFrameworkTarget + Environment.NewLine + PodLine);
|
||||
content = content.Replace(UnityFrameworkTarget, UnityFrameworkTarget + Environment.NewLine + podLine);
|
||||
File.WriteAllText(podfilePath, content);
|
||||
}
|
||||
else
|
||||
@@ -53,11 +61,11 @@ namespace Editor
|
||||
File.AppendAllText(podfilePath,
|
||||
Environment.NewLine +
|
||||
UnityFrameworkTarget + Environment.NewLine +
|
||||
PodLine + Environment.NewLine +
|
||||
podLine + Environment.NewLine +
|
||||
"end" + Environment.NewLine);
|
||||
}
|
||||
|
||||
Debug.Log("CrashReport iOS 已写入 Bugly CocoaPods 依赖,请在 Xcode 构建前执行 pod install。");
|
||||
Debug.Log($"CrashReport iOS 已写入 Bugly CocoaPods 依赖({normalizedVersion}),请在 Xcode 构建前执行 pod install。");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user