Skip to content

Instantly share code, notes, and snippets.

@nakamura001
Last active August 10, 2017 06:36
Show Gist options
  • Save nakamura001/878c91cd98550af792c4716d557ecc1c to your computer and use it in GitHub Desktop.
Save nakamura001/878c91cd98550af792c4716d557ecc1c to your computer and use it in GitHub Desktop.
UnityのiOSビルド時に特定の.aファイルを削除するサンプル
[PostProcessBuildAttribute(1)]
public static void OnPostProcessBuild (BuildTarget buildTarget, string xcodeProjectDir) {
var projectPath = xcodeProjectDir + "/Unity-iPhone.xcodeproj/project.pbxproj";
Debug.Log ("projectPath: " + projectPath);
PBXProject pbxProject = new PBXProject();
pbxProject.ReadFromFile (projectPath);
// FindFileGuidByRealPath() で指定しているファイル名は実際に削除したいファイルに変更して下さい
string guid = pbxProject.FindFileGuidByRealPath("Libraries/libiPhone-lib.a", PBXSourceTree.Source);
Debug.Log ("guid: " + guid);
if (!string.IsNullOrEmpty(guid))
{
string target = pbxProject.TargetGuidByName ("Unity-iPhone");
Debug.Log ("target: " + target);
pbxProject.RemoveFile (guid);
pbxProject.RemoveFileFromBuild (target, guid);
pbxProject.RemoveFrameworkFromProject (target, guid);
File.WriteAllText (projectPath, pbxProject.WriteToString ());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment