在导出xcode工程之后,我们有可能需要在Embedded Binaries下增加相关库的引用,为了能够集成在构建路中,可以通过一下方式,用unity提供的xcode api来实现脚本添加依赖库。
#if UNITY_EDITOR_OSX
using UnityEditor.iOS.Xcode;
using UnityEditor.iOS.Xcode.Extensions;
#endif
public class TestBuildPostprocessor {
[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) {
if (target != BuildTarget.iOS) {
UnityEngine.Debug.LogWarning ("Target is not iPhone. XCodePostProcess will not run");
return;
}
#if UNITY_EDITOR_OSX
//EmbedFrameworks
string projPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
PBXProject proj = new PBXProject();
proj.ReadFromString(File.ReadAllText(projPath));
string targetGuid = proj.TargetGuidByName("Unity-iPhone");
const string defaultLocationInProj = "Plugins/iOS";