How to use the pbxproj.PBXGenericObject function in pbxproj

To help you get started, we’ve selected a few pbxproj examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kronenthaler / mod-pbxproj / tests / TestPBXGenericObject.py View on Github external
def testParseCreateAttributes(self):
        obj = {"a": "varA", "b": [1, 2, 3], "c": {"c1": "varC1"}}
        dobj = PBXGenericObject().parse(obj)
        self.assertEqual(dobj.a, "varA")
        self.assertEqual(dobj.b, [1, 2, 3])
        self.assertIsNotNone(dobj.c)
github kronenthaler / mod-pbxproj / tests / TestPBXGenericObject.py View on Github external
def testGetItem(self):
        obj = {"a": "varA", "b": [1, 2, 3], "c": {"c1": "FDDF6A571C68E5B100D7A645"}}
        dobj = PBXGenericObject().parse(obj)

        self.assertIsInstance(dobj["c"]["c1"], PBXKey)
        self.assertIsNone(dobj['X'])
github kronenthaler / mod-pbxproj / tests / TestPBXGenericObject.py View on Github external
def testResolveComment(self):
        obj = {"a": {"name": "A"}, "b": {"path": "B"}, "c": {"c1": "FDDF6A571C68E5B100D7A645"}}
        dobj = PBXGenericObject().parse(obj)

        self.assertEqual(dobj._resolve_comment('a'), 'A')
        self.assertEqual(dobj._resolve_comment('b'), 'B')
        self.assertEqual(dobj._resolve_comment('c'), None)
github kronenthaler / mod-pbxproj / tests / TestPBXGenericObject.py View on Github external
def testPrintObject(self):
        obj = {"a": "varA", "b": [1, 2, 3], "c": {"c1": "FDDF6A571C68E5B100D7A645"}}
        dobj = PBXGenericObject().parse(obj)

        expected = '{\n\ta = varA;\n\tb = (\n\t\t1,\n\t\t2,\n\t\t3,\n\t);\n\tc = {\n\t\tc1 = FDDF6A571C68E5B100D7A645;\n\t};\n}'

        self.assertEqual(dobj.__repr__(), expected)
github kronenthaler / mod-pbxproj / tests / TestPBXGenericObject.py View on Github external
def testParseCreateObjectOfRightTypes(self):
        obj = {"objects": {"id": {"isa": "type"}}}
        dobj = PBXGenericObject().parse(obj)

        self.assertIsInstance(dobj.objects, objects)
github kronenthaler / mod-pbxproj / pbxproj / pbxsections / PBXFileReference.py View on Github external
import os
from pbxproj import PBXGenericObject


class PBXFileReference(PBXGenericObject):
    @classmethod
    def create(cls, path, tree=u'SOURCE_ROOT'):
        return cls().parse({
            u'_id': cls._generate_id(),
            u'isa': cls.__name__,
            u'path': path,
            u'name': os.path.split(path)[1],
            u'sourceTree': tree
        })

    def set_explicit_file_type(self, file_type):
        if u'lastKnownFileType' in self:
            del self[u'lastKnownFileType']
        self[u'explicitFileType'] = file_type

    def set_last_known_file_type(self, file_type):
github kronenthaler / mod-pbxproj / pbxproj / pbxsections / PBXProject.py View on Github external
def set_provisioning_style(self, provisioning_type, target):
        if u'attributes' not in self:
            self[u'attributes'] = PBXGenericObject()

        if u'TargetAttributes' not in self.attributes:
            self.attributes[u'TargetAttributes'] = PBXGenericObject()

        if target.get_id() not in self.attributes.TargetAttributes:
            self.attributes.TargetAttributes[target.get_id()] = PBXGenericObject()

        self.attributes.TargetAttributes[target.get_id()][u'ProvisioningStyle'] = provisioning_type
github kronenthaler / mod-pbxproj / pbxproj / pbxsections / XCConfigurationList.py View on Github external
from pbxproj import PBXGenericObject


class XCConfigurationList(PBXGenericObject):
    def _get_comment(self):
        info = self._get_section()
        return u'Build configuration list for {0} "{1}"'.format(*info)

    def _get_section(self):
        objects = self.get_parent()
        target = self.get_id()

        for obj in objects.get_objects_in_section(u'PBXNativeTarget', u'PBXAggregateTarget'):
            if target in obj.buildConfigurationList:
                return obj.isa, obj.name

        for obj in objects.get_objects_in_section(u'PBXProject'):
            if target in obj.buildConfigurationList:
                return obj.isa, objects[obj.targets[0]].productName
github kronenthaler / mod-pbxproj / pbxproj / pbxsections / XCBuildConfiguration.py View on Github external
import os
from collections import OrderedDict
from pbxproj import PBXGenericObject


class XCBuildConfigurationFlags:
    OTHER_CFLAGS = u'OTHER_CFLAGS'
    OTHER_LDFLAGS = u'OTHER_LDFLAGS'
    HEADER_SEARCH_PATHS = u'HEADER_SEARCH_PATHS'
    LIBRARY_SEARCH_PATHS = u'LIBRARY_SEARCH_PATHS'
    FRAMEWORK_SEARCH_PATHS = u'FRAMEWORK_SEARCH_PATHS'
    LD_RUNPATH_SEARCH_PATHS = u'LD_RUNPATH_SEARCH_PATHS'


class XCBuildConfiguration(PBXGenericObject):

    def add_flags(self, flag_name, flags):
        if u'buildSettings' not in self:
            self[u'buildSettings'] = PBXGenericObject()

        current_flags = self.buildSettings[flag_name]
        if current_flags is None:
            self.set_flags(flag_name, flags)
            return

        if not isinstance(current_flags, list):
            current_flags = [current_flags]

        if not isinstance(flags, list):
            flags = [flags]
github kronenthaler / mod-pbxproj / pbxproj / pbxsections / XCBuildConfiguration.py View on Github external
def set_flags(self, flag_name, flags):
        if u'buildSettings' not in self:
            self[u'buildSettings'] = PBXGenericObject()

        if not isinstance(flags, list):
            flags = [flags]

        self.buildSettings[flag_name] = list(OrderedDict.fromkeys(flags))