LoginSignup
5
4

More than 5 years have passed since last update.

UnityのiOSビルドで出力されるXcodeプロジェクトのEnable Bitcodeを自動でNoにする

Last updated at Posted at 2017-02-11

Xcodeプロジェクトの設定変更を自動化する

UnityのXcodeプロジェクト出力時に、Enable BitcodeをNoにするのが糞ダルいので自動化した。
PBXProjectを使えばiOSビルド時にXcodeプロジェクトの設定を書き換えられる。

using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
#endif

public static class MyBuildPostprocess
{
    [PostProcessBuild(999)]
    public static void OnPostProcessBuild( BuildTarget buildTarget, string path)
    {
        if(buildTarget == BuildTarget.iOS) {
            string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

            PBXProject pbxProject = new PBXProject();
            pbxProject.ReadFromFile(projectPath);

            string target = pbxProject.TargetGuidByName("Unity-iPhone");
            pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");

            pbxProject.WriteToFile (projectPath);
        }
    }
}

同じ要領でコンパイルフラグ等も追加できる。そのあたりの話は別記事で。
ファイル毎のARC無効設定を追加する

参考

Unity - Scripting API: PBXProject

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4