提交修改

This commit is contained in:
changyunjia
2026-06-09 15:16:52 +08:00
co-authored by changyunjia
parent d4442fc21f
commit 3ac4fe0cd0
330 changed files with 48115 additions and 36763 deletions
+28 -5
View File
@@ -3,24 +3,32 @@ using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using System.IO;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;
public class PostProcessBuild : IPostprocessBuildWithReport
{
public int callbackOrder => 1;
public void OnPostprocessBuild(UnityEditor.Build.Reporting.BuildReport report)
public void OnPostprocessBuild(BuildReport report)
{
//检查是否为 iOS 平台构建
// 检查是否为 iOS 平台构建
if (report.summary.platform == BuildTarget.iOS)
{
string projectPath = report.summary.outputPath;
string customControllerPath = "Assets/Editor/UnityAppController.mm"; // 自定义文件的路径
string projFilePath = PBXProject.GetPBXProjectPath(projectPath);
PBXProject proj = new PBXProject();
proj.ReadFromFile(projFilePath);
string targetGuid = proj.GetUnityFrameworkTargetGuid();
// 示例:复制自定义 UnityAppController.mm
string customControllerPath = "Assets/Editor/UnityAppController.mm";
string destinationPath = Path.Combine(projectPath, "Classes/UnityAppController.mm");
if (File.Exists(customControllerPath))
{
// 复制文件到 Xcode 项目中
File.Copy(customControllerPath, destinationPath, overwrite: true);
Debug.Log("Custom UnityAppController.mm has been copied to Xcode project.");
}
@@ -28,6 +36,21 @@ public class PostProcessBuild : IPostprocessBuildWithReport
{
Debug.LogError("Custom UnityAppController.mm file not found at " + customControllerPath);
}
// 示例:添加插件文件时避免重复
string pluginPath = Path.Combine(projectPath, "Libraries/Plugins/iOS/pluginIOs.mm");
if (!proj.ContainsFileByRealPath(pluginPath))
{
string fileGuid = proj.AddFile(pluginPath, "Libraries/Plugins/iOS/pluginIOs.mm", PBXSourceTree.Source);
proj.AddFileToBuild(targetGuid, fileGuid);
Debug.Log("pluginIOs.mm added to UnityFramework target.");
}
else
{
Debug.Log("pluginIOs.mm already exists, skip adding.");
}
File.WriteAllText(projFilePath, proj.WriteToString());
}
}
}
}
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 8d94ea3741ad8d344a76cca0aa62f67e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,42 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0863bf92b4fcc45b0b9267325249bf0f, type: 3}
m_Name: NotificationSettings
m_EditorClassIdentifier:
toolbarInt: 0
iOSNotificationEditorSettingsValues:
keys:
- UnityNotificationRequestAuthorizationOnAppLaunch
- UnityNotificationDefaultAuthorizationOptions
- UnityAddRemoteNotificationCapability
- UnityNotificationRequestAuthorizationForRemoteNotificationsOnAppLaunch
- UnityRemoteNotificationForegroundPresentationOptions
- UnityUseAPSReleaseEnvironment
- UnityUseLocationNotificationTrigger
values:
- True
- 7
- False
- False
- -1
- False
- False
AndroidNotificationEditorSettingsValues:
keys:
- UnityNotificationAndroidRescheduleOnDeviceRestart
- UnityNotificationAndroidUseCustomActivity
- UnityNotificationAndroidCustomActivityString
values:
- False
- False
- com.unity3d.player.UnityPlayerActivity
TrackedResourceAssets: []
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 4cee8bca36f2ab74b8feb832747fa6f4
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant: