I am trying to modify a Unity3D generated Xcode project with mod_pbxproj.py called from a python script which is triggered by a PostProcessBuild attribute. I need to set ENABLE_BITCODE = NO due to the problem described in New warnings in iOS 9.
I am a Python newbie and don't know much about the Xcode PBX internals. I tried a number of calls like
project.add_flags ('ENABLE_BITCODE=NO')
or array, dictionary, etc. variants. Everything I tried either did not do the job or threw an error in the system logs. Finally I ended up with a patch in mod_pbxproj.py which does what I want:
def add_other_buildsetting(self, flag, value):
build_configs = [b for b in self.objects.values() if b.get('isa') == 'XCBuildConfiguration']
for b in build_configs:
if b.add_other_buildsetting(flag, value):
self.modified = True
and
def add_other_buildsetting(self, flag, value):
modified = False
base = 'buildSettings'
key = flag
if not self.has_key(base):
self[base] = PBXDict()
self[base][key] = value
modified = True
return modified
Now calling project.add_other_buildsetting ('ENABLE_BITCODE', 'NO')
works almost as expected. I got 5 entries in the pbxproj file instead of the 2 changes I noticed when setting the option manually in Xcode. Anyway it seems to work so far.
But: Patching a well known piece of software feels pretty strange and I cannot believe that it is not possible to add (or modify) an option in the root of the buildSettings tree using the standard mod_pbxproj.py.
How can this be achieved?
Edit: My fork of mod_pbxproj