Skip to content

Commit

Permalink
chore: fix ios build processor
Browse files Browse the repository at this point in the history
  • Loading branch information
HarrisonHough committed Jan 16, 2024
1 parent 3dc05cd commit 8f171b2
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions Editor/IOSBuildProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
#if UNITY_IOS
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor.iOS.Xcode;

namespace ReadyPlayerMe.WebView.Editor
{
public class IOSBuildProcessor
public class IOSBuildProcessor : IPostprocessBuildWithReport
{
[PostProcessBuildAttribute(100)]
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
public int callbackOrder => 0;

public void OnPostprocessBuild(BuildReport report)
{
if (BuildTarget.iOS != target) return;
var projectPath = $"{pathToBuiltProject}/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject proj = new PBXProject();
proj.ReadFromString(File.ReadAllText(projectPath));
proj.AddFrameworkToProject(proj.TargetGuidByName("Unity-iPhone"), "WebKit.framework", false);
File.WriteAllText(projectPath, proj.WriteToString());
if (report.summary.platform != BuildTarget.iOS) return;

var projectPath = $"{report.summary.outputPath}/Unity-iPhone.xcodeproj/project.pbxproj";

var pbxProject = new PBXProject();
pbxProject.ReadFromFile(projectPath);

//Main
var targetGuid = pbxProject.GetUnityMainTargetGuid();
pbxProject.AddFrameworkToProject(targetGuid, "WebKit.framework", false);
pbxProject.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");

//Unity Tests
targetGuid = pbxProject.TargetGuidByName(PBXProject.GetUnityTestTargetName());
pbxProject.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");

//Unity Framework
targetGuid = pbxProject.GetUnityFrameworkTargetGuid();
pbxProject.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");
pbxProject.AddBuildProperty(targetGuid, "OTHER_LDFLAGS", "-ld_classic");

pbxProject.WriteToFile(projectPath);
}
}
}
Expand Down

0 comments on commit 8f171b2

Please sign in to comment.