Skip to content

Instantly share code, notes, and snippets.

@mao-test-h
Created April 25, 2020 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mao-test-h/c3f42961edee7b0f84cf9f306c8ec0be to your computer and use it in GitHub Desktop.
Save mao-test-h/c3f42961edee7b0f84cf9f306c8ec0be to your computer and use it in GitHub Desktop.
xcodeprojにccache向けの設定を適用するサンプル
#if UNITY_IOS
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
namespace Samples
{
static class CcacheSettings
{
/// <summary>
/// xcodeprojにccache向けの設定を適用するサンプル
/// </summary>
[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
{
if (buildTarget == BuildTarget.iOS)
{
var pbxProjectPath = PBXProject.GetPBXProjectPath(path);
var pbxProject = new PBXProject();
pbxProject.ReadFromString(File.ReadAllText(pbxProjectPath));
// refered to:
// https://qiita.com/tani-shi/items/e1493e63a02966ef1bac
var target = pbxProject.ProjectGuid();
pbxProject.AddBuildProperty(target, "CC", "$(DT_TOOLCHAIN_DIR)/usr/bin/ccache_wrapper");
pbxProject.SetBuildProperty(target, "LDPLUSPLUS", "$(DT_TOOLCHAIN_DIR)/usr/bin/clang++");
File.WriteAllText(pbxProjectPath, pbxProject.WriteToString());
}
}
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment