示例如下,把如下文件放到Editor目录下,打包IOS的时候就会添加CoreImage和VideoToolbox两个framework。
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEngine;
public class PostBuildiOSProcessor
{
[PostProcessBuild]
public static void OnIOSPostBuildProcess(BuildTarget buildTarget, string path)
{
#if UNITY_IOS
string projectPath = PBXProject.GetPBXProjectPath(path);
PBXProject pbxProject = new PBXProject();
pbxProject.ReadFromString(File.ReadAllText(projectPath));
string target = pbxProject.GetUnityFrameworkTargetGuid();
pbxProject.AddFileToBuild(target, pbxProject.AddFile("System/Library/Frameworks/CoreImage.framework", "Frameworks/CoreImage.framework", PBXSourceTree.Sdk));
pbxProject.AddFileToBuild(target, pbxProject.AddFile("System/Library/Frameworks/VideoToolbox.framework", "Frameworks/VideoToolbox.framework", PBXSourceTree.Sdk));
string appTarget = pbxProject.GetUnityMainTargetGuid();
File.WriteAllText(projectPath, pbxProject.WriteToString());
#endif
}
}