简体   繁体   English

Xcode / mod_pbxproj:如何设置ENABLE_BITCODE

[英]Xcode / mod_pbxproj: How to set ENABLE_BITCODE

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. 我正在尝试使用由PostProcessBuild属性触发的python脚本调用的mod_pbxproj.py修改Unity3D生成的Xcode项目。 I need to set ENABLE_BITCODE = NO due to the problem described in New warnings in iOS 9 . 由于iOS 9中的“ 新警告”中所述的问题,我需要设置ENABLE_BITCODE = NO

I am a Python newbie and don't know much about the Xcode PBX internals. 我是Python新手,对Xcode PBX内部知识不多。 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: 最后,我在mod_pbxproj.py中获得了一个补丁,该补丁可以实现我想要的功能:

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. 现在调用project.add_other_buildsetting ('ENABLE_BITCODE', 'NO')几乎可以正常工作。 I got 5 entries in the pbxproj file instead of the 2 changes I noticed when setting the option manually in Xcode. 我在pbxproj文件中有5个条目,而不是在Xcode中手动设置选项时注意到的2个更改。 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. 但是:修补一个著名的软件感觉很奇怪,我无法相信不可能使用标准的mod_pbxproj.py在buildSettings树的根目录中添加(或修改)一个选项。

How can this be achieved? 如何做到这一点?

Edit: My fork of mod_pbxproj 编辑: 的mod_pbxproj的叉子

As long as you have latest mod_pbxproj.py this works fine: 只要您拥有最新的mod_pbxproj.py可以正常工作:

project.add_flags({'ENABLE_BITCODE':'NO'})

You can get mod_pbxproj.py from here: https://github.com/kronenthaler/mod-pbxproj/blob/master/mod_pbxproj/mod_pbxproj.py :你可以从这里得到mod_pbxproj.py https://github.com/kronenthaler/mod-pbxproj/blob/master/mod_pbxproj/mod_pbxproj.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM