Last active
August 10, 2017 06:36
-
-
Save nakamura001/878c91cd98550af792c4716d557ecc1c to your computer and use it in GitHub Desktop.
UnityのiOSビルド時に特定の.aファイルを削除するサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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