using UnityEngine;
|
#if UNITY_EDITOR
|
using UnityEditor;
|
using UnityEditor.Callbacks;
|
using UnityEditor.XCodeEditor;
|
#endif
|
using System.IO;
|
|
public static class XCodePostProcess
|
{
|
|
#if UNITY_EDITOR
|
[PostProcessBuild(999)]
|
public static void OnPostProcessBuild( BuildTarget target, string pathToBuiltProject )
|
{
|
#if UNITY_5
|
if (target != BuildTarget.iOS) {
|
#else
|
if (target != BuildTarget.iPhone) {
|
#endif
|
Debug.LogWarning("Target is not iPhone. XCodePostProcess will not run");
|
return;
|
}
|
|
// Create a new project object from build target
|
XCProject project = new XCProject( pathToBuiltProject );
|
|
// Find and run through all projmods files to patch the project.
|
// Please pay attention that ALL projmods files in your project folder will be excuted!
|
string[] files = Directory.GetFiles( Application.dataPath, "*.projmods", SearchOption.AllDirectories );
|
foreach( string file in files ) {
|
UnityEngine.Debug.Log("ProjMod File: "+file);
|
project.ApplyMod( file );
|
}
|
|
//TODO disable the bitcode for iOS 9
|
project.overwriteBuildSetting("ENABLE_BITCODE", "NO", "Release");
|
project.overwriteBuildSetting("ENABLE_BITCODE", "NO", "Debug");
|
|
//TODO implement generic settings as a module option
|
// project.overwriteBuildSetting("CODE_SIGN_IDENTITY[sdk=iphoneos*]", "iPhone Distribution", "Release");
|
|
// Finally save the xcode project
|
project.Save();
|
|
}
|
#endif
|
|
public static void Log(string message)
|
{
|
UnityEngine.Debug.Log("PostProcess: "+message);
|
}
|
}
|