I’m working on a project for a client who has provided their SDK. It needs to be added to the “Embedded Binaries” section of the XCode project for it to work. There doesn’t seem to be a way to do this automagically from Unity which breaks our build process.
I’ve found these links but none provide a solution:
Does this function already exist in the latest Unity (5.4.0) in some form? If not, what work arounds have others been using? I can’t be the first to be using a 3rd party framework with an automated build process.
Not sure this will help, but take a look at XUPorter GitHub - onevcat/XUPorter: Add files and frameworks to your Xcode project after it is generated by Unity 3D.. It is used as Unity plugin to do post-build task to configure XCode’s building stuff. I took a peek there once and it’s not complete and not all build setting / build phases can be configured. But the code is clean enough that you might want to modify to suite your need.
using UnityEditor.iOS.Xcode;
using UnityEditor.iOS.Xcode.Extensions;
#endif
public class TestBuildPostprocessor {
[PostProcessBuildAttribute(100)]
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”;
const string coreFrameworkName = “test.framework”;
string framework = Path.Combine(defaultLocationInProj, coreFrameworkName);
string fileGuid = proj.AddFile(framework, “Frameworks/” + framework, PBXSourceTree.Sdk);
PBXProjectExtensions.AddFileToEmbedFrameworks(proj, targetGuid, fileGuid);
proj.SetBuildProperty(targetGuid, “LD_RUNPATH_SEARCH_PATHS”, “$(inherited) @executable_path/Frameworks”);
proj.WriteToFile (projPath);
//EmbedFrameworks end #endif
}
}
The above code works for Unity 2017 and up, for Unity 5.6, anyone knows if there is a way to embed frameworks without AddFileToEmbedFrameworks? Looks like there is no such thing on Unity 5.6