Last active
April 13, 2020 00:11
-
-
Save mattbajorek/b6bc153905124a45119903354f3fd52e to your computer and use it in GitHub Desktop.
iOS Editor BuildPostProcessor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using UnityEditor.Callbacks; | |
using UnityEditor.iOS.Xcode; | |
using System.IO; | |
using System.Linq; | |
public class BuildPostProcessor | |
{ | |
[PostProcessBuild] | |
public static void OnPostProcessBuild(BuildTarget target, string path) | |
{ | |
if (target == BuildTarget.iOS) | |
{ | |
// Get project into C# | |
var projectPath = PBXProject.GetPBXProjectPath(path); | |
var project = new PBXProject(); | |
project.ReadFromFile(projectPath); | |
// Get targetGUID | |
var targetName = PBXProject.GetUnityTargetName(); | |
var targetGUID = project.TargetGuidByName(targetName); | |
// Built in Frameworks | |
project.AddFrameworkToProject(targetGUID, "Foundation.framework", false); | |
Debug.Log("Added iOS frameworks to project"); | |
... | |
// Add `-ObjC` to "Other Linker Flags". | |
project.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-ObjC"); | |
// Overwrite | |
project.WriteToFile(projectPath); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment