Created
July 2, 2015 03:08
-
-
Save keijiro/25bab1bb04de432f709f to your computer and use it in GitHub Desktop.
(Unity Xcode Manipulation API) An example which modifies compiler flags for a given source file.
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; | |
public class PbxModifier | |
{ | |
[PostProcessBuild] | |
public static void OnPostprocessBuild(BuildTarget buildTarget, string path) | |
{ | |
if (buildTarget == BuildTarget.iOS) { | |
string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj"; | |
PBXProject proj = new PBXProject(); | |
proj.ReadFromString(File.ReadAllText(projPath)); | |
string target = proj.TargetGuidByName("Unity-iPhone"); | |
string file = proj.FindFileGuidByProjectPath("Classes/UnityAppController.mm"); | |
var flags = proj.GetCompileFlagsForFile(target, file); | |
flags.Add("-fno-objc-arc"); | |
proj.SetCompileFlagsForFile(target, file, flags); | |
File.WriteAllText(projPath, proj.WriteToString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where to put this file in Unity Project?