提交sdk
This commit is contained in:
Vendored
BIN
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d17262a9ec3b482b90dc484b4af0e0d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,57 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using System.IO;
|
||||
#if UNITY_IOS
|
||||
using UnityEditor.iOS.Xcode;
|
||||
#endif
|
||||
|
||||
public class MoveLibToClasses
|
||||
{
|
||||
// PostProcessBuild 属性确保这段代码在 Unity 导出 Xcode 工程完成后自动执行
|
||||
[PostProcessBuild(999)]
|
||||
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (target != BuildTarget.iOS) return;
|
||||
|
||||
#if UNITY_IOS
|
||||
// 1. 定义源文件路径和目标文件路径
|
||||
string fileName = "libweb.a";
|
||||
string sourcePath = Path.Combine(Application.dataPath, "Editor", fileName);
|
||||
string destDir = Path.Combine(pathToBuiltProject, "Classes");
|
||||
string destPath = Path.Combine(destDir, fileName);
|
||||
|
||||
// 检查源文件是否存在
|
||||
if (!File.Exists(sourcePath))
|
||||
{
|
||||
Debug.LogError($"[MoveLib] 找不到源文件: {sourcePath}");
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 物理复制文件到 Xcode 工程的 Classes 文件夹中
|
||||
if (!Directory.Exists(destDir))
|
||||
{
|
||||
Directory.CreateDirectory(destDir);
|
||||
}
|
||||
File.Copy(sourcePath, destPath, true);
|
||||
Debug.Log($"[MoveLib] 成功将库复制到: {destPath}");
|
||||
|
||||
// 3. 修改 Xcode 工程文件(PBXProject),将文件注册到 Xcode 中
|
||||
string pbxProjectPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
|
||||
PBXProject project = new PBXProject();
|
||||
project.ReadFromString(File.ReadAllText(pbxProjectPath));
|
||||
|
||||
string targetGuid = project.GetUnityFrameworkTargetGuid(); // 或者 project.TargetGuidByName(PBXProject.GetUnityTargetName())
|
||||
|
||||
// 将文件添加到 Xcode 的 Classes 引用中 (相对于工程根目录路径为 "Classes/libwebview_jiami.a")
|
||||
string fileGuid = project.AddFile("Classes/" + fileName, "Classes/" + fileName, PBXSourceTree.Source);
|
||||
|
||||
// 将该 .a 文件加入到编译链接中
|
||||
project.AddFileToBuild(targetGuid, fileGuid);
|
||||
|
||||
// 保存对 Xcode 工程的修改
|
||||
File.WriteAllText(pbxProjectPath, project.WriteToString());
|
||||
Debug.Log("[MoveLib] Xcode 工程配置已成功更新!");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3e9d2c715ee243f69917123d92ce015
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 225a747de20d14e4db5b5ddc85aadda7
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Reference in New Issue
Block a user