def testEmbedFrameworkInRightCopySection(self):
        project = XcodeProject(self.obj)
        self.assertEqual(project.objects.get_objects_in_section(u'PBXCopyFilesBuildPhase').__len__(), 1)

        project.add_file('X.framework', file_options=FileOptions(embed_framework=True))

        self.assertEqual(project.objects.get_objects_in_section(u'PBXCopyFilesBuildPhase').__len__(), 3)
    def testAddFileFrameworkWithAbsolutePath(self):
        project = XcodeProject(self.obj)
        project.add_file(os.path.abspath("samples/test.framework"))

        expected_flags = ["$(SRCROOT)/tests/samples", "$(inherited)"]
        self.assertListEqual(project.objects['5'].buildSettings.FRAMEWORK_SEARCH_PATHS, expected_flags)
        self.assertListEqual(project.objects['6'].buildSettings.FRAMEWORK_SEARCH_PATHS, expected_flags)
        self.assertListEqual(project.objects['7'].buildSettings.FRAMEWORK_SEARCH_PATHS, expected_flags)
        self.assertListEqual(project.objects['8'].buildSettings.FRAMEWORK_SEARCH_PATHS, expected_flags)
    def testRemoveFilesByPath(self):
        project = XcodeProject(self.obj)
        original = project.__str__()
        project.add_file("file.m")

        result = project.remove_files_by_path('file.m')

        self.assertTrue(result)
        self.assertEqual(project.__str__(), original)
    def testAddFileLibraryWithAbsolutePath(self):
        project = XcodeProject(self.obj)
        project.add_file(os.path.abspath("samples/testLibrary.a"))

        expected_flags = "$(SRCROOT)/tests/samples"
        self.assertEqual(project.objects['5'].buildSettings.LIBRARY_SEARCH_PATHS, expected_flags)
        self.assertEqual(project.objects['6'].buildSettings.LIBRARY_SEARCH_PATHS, expected_flags)
        self.assertEqual(project.objects['7'].buildSettings.LIBRARY_SEARCH_PATHS, expected_flags)
        self.assertEqual(project.objects['8'].buildSettings.LIBRARY_SEARCH_PATHS, expected_flags)
Esempio n. 5
0
    def testAddFileIfExists(self):
        project = XcodeProject(self.obj)
        build_file = project.add_file("file.m", force=False)

        # 2 source files are created 1 x target
        self.assertEqual(project.objects.get_objects_in_section(u'PBXSourcesBuildPhase').__len__(), 2)
        self.assertEqual(build_file.__len__(), 2)

        build_file = project.add_file("file.m", force=False)
        self.assertEqual(build_file, [])
    def testRemoveFileById(self):
        project = XcodeProject(self.obj)
        original = project.__str__()
        project.add_file("file.m")

        file = project.get_files_by_name('file.m')[0]
        result = project.remove_file_by_id(file.get_id())

        self.assertTrue(result)
        self.assertEqual(project.__str__(), original)
    def testRemoveFileByIdFromTarget(self):
        project = XcodeProject(self.obj)
        project.add_file("file.m")

        file_ref = project.get_files_by_name('file.m')[0]
        result = project.remove_file_by_id(file_ref.get_id(), target_name='report')

        self.assertTrue(result)
        self.assertIsNotNone(project.objects[file_ref.get_id()])
        self.assertEqual(project.objects.get_objects_in_section('PBXBuildFile').__len__(), 3)
        self.assertEqual(project.objects.get_objects_in_section('PBXSourcesBuildPhase').__len__(), 1)
    def testRemoveFileByIdKeepShellScriptBuildPhases(self):
        project = XcodeProject(self.obj)
        project.add_run_script('ls -la')

        original = project.__str__()
        project.add_file("file.m")

        file = project.get_files_by_name('file.m')[0]
        result = project.remove_file_by_id(file.get_id())

        self.assertTrue(result)
        self.assertEqual(project.__str__(), original)
Esempio n. 9
0
    def testAddFileUnknownAllowed(self):
        project = XcodeProject(self.obj)
        build_file = project.add_file("file.unknowntype", file_options=FileOptions(ignore_unknown_type=True))

        # unknown files are added as resources
        self.assertEqual(project.objects.get_objects_in_section(u'PBXResourcesBuildPhase').__len__(), 2)
        self.assertEqual(build_file.__len__(), 2)
Esempio n. 10
0
    def testAddFileNoCreateBuildFiles(self):
        project = XcodeProject(self.obj)
        items = project.objects.__len__()
        build_file = project.add_file(".", file_options=FileOptions(create_build_files=False))

        # no create build file flag
        self.assertEqual(project.objects.__len__(), items)
        self.assertEqual(build_file, [])
Esempio n. 11
0
    def testAddFileWithAbsolutePathOnUnknownTree(self):
        project = XcodeProject(self.obj)
        build_file = project.add_file(os.path.abspath("samples/test.framework"), tree='DEVELOPER_DIR')

        self.assertEqual(project.objects[build_file[0].fileRef].sourceTree, '<absolute>')
        self.assertEqual(project.objects[build_file[1].fileRef].sourceTree, '<absolute>')
        self.assertEqual(project.objects[build_file[2].fileRef].sourceTree, '<absolute>')
        self.assertEqual(project.objects[build_file[3].fileRef].sourceTree, '<absolute>')
Esempio n. 12
0
    def testAddFileFrameworkFromSDKRootIgnoresEmbedAndCodeSign(self):
        project = XcodeProject(self.obj)
        options = FileOptions(create_build_files=True, weak=True, embed_framework=True, code_sign_on_copy=True)
        build_file = project.add_file("file.framework", tree=TreeType.SDKROOT, file_options=options)

        # 2 source files are created 1 x target
        self.assertEqual(project.objects.get_objects_in_section(u'PBXFrameworksBuildPhase').__len__(), 2)
        self.assertEqual(project.objects.get_objects_in_section(u'PBXCopyFilesBuildPhase').__len__(), 3)
        self.assertEqual(build_file.__len__(), 4)
        self.assertListEqual(build_file[0].settings.ATTRIBUTES, [u'Weak'])
        self.assertIsNone(build_file[1]['settings'])
        self.assertListEqual(build_file[2].settings.ATTRIBUTES, [u'Weak'])
        self.assertIsNone(build_file[3]['settings'])
Esempio n. 13
0
    def testAddFileOfAllTypes(self):
        for ext in ProjectFiles._FILE_TYPES:
            project = XcodeProject(self.obj)
            options = FileOptions(embed_framework=False)
            build_file = project.add_file("file{0}".format(ext), file_options=options)

            _, phase = ProjectFiles._FILE_TYPES[ext]
            amount = 0
            if phase is not None:
                amount = 2

            self.assertEqual(project.objects.get_objects_in_section(phase).__len__(), amount)
            self.assertEqual(build_file.__len__(), amount)
Esempio n. 14
0
    def testAddFileFrameworkEmbedded(self):
        project = XcodeProject(self.obj)
        options = FileOptions(create_build_files=True, weak=True, embed_framework=True, code_sign_on_copy=True)
        build_file = project.add_file("file.framework", file_options=options)

        # 2 source files are created 1 x target
        self.assertEqual(project.objects.get_objects_in_section(u'PBXFrameworksBuildPhase').__len__(), 2)
        self.assertEqual(project.objects.get_objects_in_section(u'PBXCopyFilesBuildPhase').__len__(), 2)
        self.assertEqual(build_file.__len__(), 4)
        self.assertListEqual(build_file[0].settings.ATTRIBUTES, [u'Weak', u'CodeSignOnCopy', u'RemoveHeadersOnCopy'])
        self.assertListEqual(build_file[1].settings.ATTRIBUTES, [u'Weak', u'CodeSignOnCopy', u'RemoveHeadersOnCopy'])
        self.assertListEqual(build_file[2].settings.ATTRIBUTES, [u'Weak', u'CodeSignOnCopy', u'RemoveHeadersOnCopy'])
        self.assertListEqual(build_file[3].settings.ATTRIBUTES, [u'Weak', u'CodeSignOnCopy', u'RemoveHeadersOnCopy'])
Esempio n. 15
0
    def testAddFileOfAllTypes(self):
        for ext in ProjectFiles._FILE_TYPES:
            project = XcodeProject(self.obj)
            options = FileOptions(embed_framework=False)
            build_file = project.add_file("file{0}".format(ext),
                                          file_options=options)

            _, phase = ProjectFiles._FILE_TYPES[ext]
            amount = 0
            if phase is not None:
                amount = 2

            self.assertEqual(
                project.objects.get_objects_in_section(phase).__len__(),
                amount)
            self.assertEqual(build_file.__len__(), amount)
Esempio n. 16
0
    def testAddHeaderFileProjectScope(self):
        project = XcodeProject({
            'objects': {
                '2': {'isa': 'PBXAggregateTarget', 'name': 'report', 'buildConfigurationList': '4',
                      'buildPhases': []},
                '4': {'isa': 'XCConfigurationList', 'buildConfigurations': ['7', '8']},
                '7': {'isa': 'XCBuildConfiguration', 'name': 'Release', 'id': '7'},
                '8': {'isa': 'XCBuildConfiguration', 'name': 'Debug', 'id': '8'},
                'project': {'isa': 'PBXProject'}
            }
        })

        self.assertEqual(project.get_build_phases_by_name(u'PBXHeadersBuildPhase').__len__(), 0)

        references = project.add_file("header.h", file_options=FileOptions())

        self.assertGreater(project.get_build_phases_by_name(u'PBXHeadersBuildPhase').__len__(), 0)
        self.assertIsNone(references[0]['settings'], None)
Esempio n. 17
0
    def testAddFileFrameworkEmbedded(self):
        project = XcodeProject(self.obj)
        options = FileOptions(create_build_files=True,
                              weak=True,
                              embed_framework=True,
                              code_sign_on_copy=True)
        build_file = project.add_file("file.framework", file_options=options)

        # 2 source files are created 1 x target
        self.assertEqual(
            project.objects.get_objects_in_section(
                u'PBXFrameworksBuildPhase').__len__(), 2)
        self.assertEqual(
            project.objects.get_objects_in_section(
                u'PBXCopyFilesBuildPhase').__len__(), 3)
        self.assertEqual(build_file.__len__(), 4)
        self.assertListEqual(build_file[0].settings.ATTRIBUTES, [u'Weak'])
        self.assertListEqual(build_file[1].settings.ATTRIBUTES,
                             [u'CodeSignOnCopy', u'RemoveHeadersOnCopy'])
        self.assertListEqual(build_file[2].settings.ATTRIBUTES, [u'Weak'])
        self.assertListEqual(build_file[3].settings.ATTRIBUTES,
                             [u'CodeSignOnCopy', u'RemoveHeadersOnCopy'])
Esempio n. 18
0
    def testAddFileFrameworkFromSDKRootIgnoresEmbedAndCodeSign(self):
        project = XcodeProject(self.obj)
        options = FileOptions(create_build_files=True,
                              weak=True,
                              embed_framework=True,
                              code_sign_on_copy=True)
        build_file = project.add_file("file.framework",
                                      tree=TreeType.SDKROOT,
                                      file_options=options)

        # 2 source files are created 1 x target
        self.assertEqual(
            project.objects.get_objects_in_section(
                u'PBXFrameworksBuildPhase').__len__(), 2)
        self.assertEqual(
            project.objects.get_objects_in_section(
                u'PBXCopyFilesBuildPhase').__len__(), 3)
        self.assertEqual(build_file.__len__(), 4)
        self.assertListEqual(build_file[0].settings.ATTRIBUTES, [u'Weak'])
        self.assertIsNone(build_file[1]['settings'])
        self.assertListEqual(build_file[2].settings.ATTRIBUTES, [u'Weak'])
        self.assertIsNone(build_file[3]['settings'])
project.add_flags('GCC_PREPROCESSOR_DEFINITIONS', 'MURKA_OFFSCREEN')

# removing extra files

project.remove_files_by_path("src/ofApp.cpp")
project.remove_files_by_path("src/ofApp.h")
project.remove_files_by_path("src/main.cpp")

# adding files

group = project.get_or_create_group('hotjuice_source')
project.add_folder(hotjuice_path + "/src", parent=group)

# add additional sources
for filePath in include_files:
    project.add_file(filePath)

# setting bundle id

project.set_flags('PRODUCT_BUNDLE_IDENTIFIER', bundle_id)

project.save()

appsupport_path = "~/Library/Application\ Support/" + company_name + "/" + bundle_id
print(appsupport_path)

# creating symlink to final build folder
os.system("ln -s " + appsupport_path + " Final_path")

# deleting pycache files
os.system('find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf')
Esempio n. 20
0
    def testAddFileNoPath(self):
        project = XcodeProject(self.obj)
        build_file = project.add_file(".", tree=None)

        # no tree or no path cannot be added
        self.assertIsNone(build_file)
Esempio n. 21
0
 def testAddFileUnknown(self):
     project = XcodeProject(self.obj)
     with self.assertRaisesRegexp(ValueError, '^Unknown file extension: '):
         project.add_file("file.unknowntype")
Esempio n. 22
0
    def testAddReferenceFile(self):
        project = XcodeProject(self.obj, path="tests/project.pbxproj")
        build_file = project.add_file(os.path.abspath("samples/dirA"))

        self.assertEqual(project.objects.get_objects_in_section(u'PBXResourcesBuildPhase').__len__(), 2)
        self.assertEqual(build_file.__len__(), 2)
Esempio n. 23
0
    def testAddFileWithAbsolutePathDoesNotExist(self):
        project = XcodeProject(self.obj)
        build_file = project.add_file(os.path.abspath("samples/unexistingFile.m"))

        # nothing to do if the file is absolute but doesn't exist
        self.assertIsNone(build_file)