Skip to content

Instantly share code, notes, and snippets.

@naichilab
Created September 16, 2015 17:30
Show Gist options
  • Save naichilab/0a8cab55675026ca6ff1 to your computer and use it in GitHub Desktop.
Save naichilab/0a8cab55675026ca6ff1 to your computer and use it in GitHub Desktop.
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