From bb20a8f4fff0653cb00281a194d587d485f803ce Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Wed, 8 Aug 2012 19:04:52 -0700 Subject: [PATCH] pbxprojModifier.py now uses the mod_pbxproj --- Tools/XcodeCapp/pbxprojModifier.py | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 Tools/XcodeCapp/pbxprojModifier.py diff --git a/Tools/XcodeCapp/pbxprojModifier.py b/Tools/XcodeCapp/pbxprojModifier.py new file mode 100755 index 000000000..515c2b860 --- /dev/null +++ b/Tools/XcodeCapp/pbxprojModifier.py @@ -0,0 +1,56 @@ +import sys, os +from mod_pbxproj import XcodeProject + + +def add_file(PBXProjectFilePath, path): + + project = XcodeProject.Load(PBXProjectFilePath) + shadowGroup = project.get_or_create_group('Shadows') + + files = project.get_files_by_os_path("XcodeSupport/%s" % os.path.basename(path)) + + if "main.m" in path: + sys.exit(0) + + if len(files) == 0: + project.add_file(path, parent=shadowGroup) + project.save() + +def remove_file(PBXProjectFilePath, path): + + project = XcodeProject.Load(PBXProjectFilePath) + shadowGroup = project.get_or_create_group('Shadows') + + files = project.get_files_by_os_path("XcodeSupport/%s" % os.path.basename(path)) + + if "main.m" in path: + sys.exit(0) + + if len(files) == 1: + project.remove_file("XcodeSupport/%s" % os.path.basename(path), parent=shadowGroup) + project.save() + + +if __name__ == '__main__': + + action = sys.argv[1] + PBXProjectFilePath = sys.argv[2] + currentFilePath = sys.argv[3] + + if action == "add": + add_file(PBXProjectFilePath, currentFilePath) + elif action == "remove": + remove_file(PBXProjectFilePath, currentFilePath) + + + + + + + + + + + + + \ No newline at end of file