Created
September 16, 2015 17:30
-
-
Save naichilab/0a8cab55675026ca6ff1 to your computer and use it in GitHub Desktop.
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.Collections; | |
using System.IO; | |
public class PostBuildProcess | |
{ | |
internal static void CopyAndReplaceDirectory (string srcPath, string dstPath) | |
{ | |
if (Directory.Exists (dstPath)) | |
Directory.Delete (dstPath); | |
if (File.Exists (dstPath)) | |
File.Delete (dstPath); | |
Directory.CreateDirectory (dstPath); | |
foreach (var file in Directory.GetFiles(srcPath)) | |
File.Copy (file, Path.Combine (dstPath, Path.GetFileName (file))); | |
foreach (var dir in Directory.GetDirectories(srcPath)) | |
CopyAndReplaceDirectory (dir, Path.Combine (dstPath, Path.GetFileName (dir))); | |
} | |
[PostProcessBuild] | |
public static void OnPostProcessBuild (BuildTarget buildTarget, string path) | |
{ | |
if (buildTarget == BuildTarget.iOS) { | |
ProcessForiOS (path); | |
} | |
} | |
private static void ProcessForiOS (string path) | |
{ | |
string pjPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj"; | |
PBXProject pj = new PBXProject (); | |
pj.ReadFromString (File.ReadAllText (pjPath)); | |
string target = pj.TargetGuidByName ("Unity-iPhone"); | |
pj.SetBuildProperty (target, "CLANG_ENABLE_MODULES", "YES"); | |
File.WriteAllText (pjPath, pj.WriteToString ()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment