Пример #1
0
def _add(project, args):
    options = FileOptions(
        create_build_files=not args[u'--no-create-build-files'],
        weak=args[u'--weak'],
        ignore_unknown_type=args[u'--ignore-unknown-types'],
        embed_framework=not args[u'--no-embed'],
        code_sign_on_copy=args[u'--sign-on-copy'])
    build_files = project.add_file(args[u'<path>'],
                                   tree=args[u'--tree'],
                                   force=False,
                                   target_name=args[u'--target'],
                                   file_options=options)
    # print some information about the build files created.
    if build_files is None:
        raise Exception(u'No files were added to the project.')

    if not build_files:
        return u'File added to the project, no build file sections created.'

    info = {}
    for build_file in build_files:
        if build_file.isa not in info:
            info[build_file.isa] = 0
        info[build_file.isa] += 1

    summary = u'File added to the project.'
    for k in info:
        summary += u'\n{0} {1} sections created.'.format(info[k], k)
    return summary
Пример #2
0
 def add_Facebook(self):
     parent_path = os.path.dirname(self.xcodeProjectRootPath)
     sDKResourcePath= os.path.join(parent_path, 'sdks/Facebook')
     file_options = FileOptions(weak=False,embed_framework=False,code_sign_on_copy=False)
     self.project.add_file(sDKResourcePath+'/FBAudienceNetwork.framework', force=False,  parent=self.frameworksGroupID,file_options=file_options,tree='SDKROOT')
     self.project.add_flags('FRAMEWORK_SEARCH_PATHS',sDKResourcePath+'/**',self.targetName)
     pass
Пример #3
0
 def add_Adview(self):
     parent_path = os.path.dirname(self.xcodeProjectRootPath)
     sDKResourcePath= os.path.join(parent_path, 'sdks/Adview')
     #库文件a
     file_options = FileOptions(weak=False,embed_framework=False,code_sign_on_copy=False)
     self.project.add_file(sDKResourcePath+'/libAdCompViewSDK.a', force=False,  parent=self.frameworksGroupID,file_options=file_options,tree='SDKROOT')
     # self.project.add_flags('_SEARCH_PATHS',sDKResourcePath+'/**',self.targetName)
     self.project.add_library_search_paths([sDKResourcePath],recursive=True)
     #资源文件.png
     files=self.eachFile(sDKResourcePath+'/res',postfix=".png")
     files_temp=self.scan_files(sDKResourcePath+'/res',postfix=".png")
     for file in files:
         self.project.add_file(file, force=False,  parent=self.frameworksGroupID,file_options=file_options,tree='SDKROOT')
     #源代码文件
     self.modifyXCodeFileCompilerFlag(os.path.join(sDKResourcePath,"TouchJSON/CDataScanner.m"))
     self.modifyXCodeFileCompilerFlag(os.path.join(sDKResourcePath,'TouchJSON/Experimental/CFilteringJSONSerializer.m'))
     self.modifyXCodeFileCompilerFlag(os.path.join(sDKResourcePath,'TouchJSON/Experimental/CJSONDeserializer_BlocksExtensions.m'))
     self.modifyXCodeFileCompilerFlag(os.path.join(sDKResourcePath,'TouchJSON/Experimental/CJSONSerialization.m'))
     self.modifyXCodeFileCompilerFlag(os.path.join(sDKResourcePath,'TouchJSON/Experimental/CJSONSerializedData.m'))      
     self.modifyXCodeFileCompilerFlag(os.path.join(sDKResourcePath,'TouchJSON/Extensions/CDataScanner_Extensions.m'))
     self.modifyXCodeFileCompilerFlag(os.path.join(sDKResourcePath,'TouchJSON/Extensions/NSDictionary_JSONExtensions.m'))     
     self.modifyXCodeFileCompilerFlag(os.path.join(sDKResourcePath,'TouchJSON/JSON/CJSONDeserializer.m'))
     self.modifyXCodeFileCompilerFlag(os.path.join(sDKResourcePath,'TouchJSON/JSON/CJSONScanner.m'))
     self.modifyXCodeFileCompilerFlag(os.path.join(sDKResourcePath,'TouchJSON/JSON/CJSONSerializer.m'))
     self.project.add_header_search_paths([sDKResourcePath],recursive=True)
     pass
Пример #4
0
def _add(project, args):
    if u'--header-scope' not in args or args[u'--header-scope'] not in ['public', 'private', 'project']:
        header_scope = u'project'
    else:
        header_scope = args[u'--header-scope']

    options = FileOptions(create_build_files=not args[u'--no-create-build-files'],
                          weak=args[u'--weak'],
                          ignore_unknown_type=args[u'--ignore-unknown-types'],
                          embed_framework=not args[u'--no-embed'],
                          code_sign_on_copy=args[u'--sign-on-copy'],
                          header_scope=header_scope)

    build_files = project.add_folder(args[u'<path>'], excludes=args[u'--exclude'], recursive=args[u'--recursive'],
                                     create_groups=not args[u'--no-create-groups'], target_name=args[u'--target'],
                                     file_options=options)
    # print some information about the build files created.
    if build_files is None:
        raise Exception(u'No files were added to the project.')

    if not build_files:
        return u'Folder added to the project, no build file sections created.'

    info = {}
    for build_file in build_files:
        if build_file.isa not in info:
            info[build_file.isa] = 0
        info[build_file.isa] += 1

    summary = u'Folder added to the project.'
    for k in info:
        summary += u'\n{0} {1} sections created.'.format(info[k], k)
    return summary
Пример #5
0
 def add_Adcolony(self):
     parent_path = os.path.dirname(self.xcodeProjectRootPath)
     sDKResourcePath= os.path.join(parent_path, 'sdks/Adcolony')
     #库文件.framework
     file_options = FileOptions(weak=False,embed_framework=False,code_sign_on_copy=False)
     self.project.add_file(sDKResourcePath+'/Adcolony.framework', force=False,  parent=self.frameworksGroupID,file_options=file_options,tree='SDKROOT')
     self.project.add_framework_search_paths([sDKResourcePath],recursive=True)
     pass
Пример #6
0
 def addSystemFrameworkOrDylib(self,project):
     strongFileOptions=FileOptions(weak=False,embed_framework=False,code_sign_on_copy=False)
     frameworksGroupID=self.frameworksGroupID
     project.add_file('usr/lib/libxml2.dylib',         force=False,  file_options=strongFileOptions,             parent=frameworksGroupID, tree='SDKROOT')
     project.add_file('usr/lib/libsqlite3.dylib',        force=False,      file_options=strongFileOptions,         parent=frameworksGroupID, tree='SDKROOT')
     project.add_file('usr/lib/libz.dylib',           force=False,         file_options=strongFileOptions,         parent=frameworksGroupID, tree='SDKROOT')
     project.add_file('usr/lib/libc++.dylib',      force=False,        file_options=strongFileOptions,               parent=frameworksGroupID, tree='SDKROOT')
     project.add_file('usr/lib/libsqlite3.0.dylib',    force=False,     file_options=strongFileOptions,                    parent=frameworksGroupID, tree='SDKROOT')
     # project.add_file('usr/lib/libstdc++.6.dylib',                          parent=frameworksGroupID, tree='SDKROOT')
     # project.add_file('usr/lib/libstdc++.dylib',                          parent=frameworksGroupID, tree='SDKROOT')
     # project.add_file('usr/lib/libstdc++.6.0.9.dylib',                          parent=frameworksGroupID, tree='SDKROOT')
     project.add_file('usr/lib/libxml2.2.dylib',          force=False,   file_options=strongFileOptions,                parent=frameworksGroupID, tree='SDKROOT')
     project.add_file('System/Library/Frameworks/CoreBluetooth.framework', file_options=strongFileOptions,   force=False, parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/GLKit.framework',file_options=strongFileOptions,   force=False,  parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/AudioToolbox.framework',file_options=strongFileOptions,   force=False,  parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/CoreFoundation.framework',file_options=strongFileOptions,  force=False,   parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/ImageIO.framework', file_options=strongFileOptions,   force=False, parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/AdSupport.framework',file_options=strongFileOptions,    force=False, parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/AVFoundation.framework', file_options=strongFileOptions,  force=False,  parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/CoreMedia.framework', file_options=strongFileOptions,  force=False,  parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/Foundation.framework',file_options=strongFileOptions,  force=False,   parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/Security.framework', file_options=strongFileOptions,  force=False,  parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/UIKit.framework',  file_options=strongFileOptions,  force=False, parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/CoreVideo.framework',file_options=strongFileOptions,   force=False,  parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/CFNetwork.framework',file_options=strongFileOptions,   force=False,  parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/MobileCoreServices.framework',file_options=strongFileOptions,   force=False,  parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/CoreData.framework',  file_options=strongFileOptions,  force=False, parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/CoreMotion.framework', file_options=strongFileOptions,   force=False, parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/EventKitUI.framework', file_options=strongFileOptions,  force=False,  parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/EventKit.framework',  file_options=strongFileOptions,  force=False, parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/MessageUI.framework', file_options=strongFileOptions,  force=False,  parent=frameworksGroupID,tree='SDKROOT')
     file_options = FileOptions(weak=True,embed_framework=False,code_sign_on_copy=False)
     project.add_file('System/Library/Frameworks/Social.framework', force=False,  parent=frameworksGroupID,file_options=file_options,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/Twitter.framework',file_options=strongFileOptions,    force=False, parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/CoreGraphics.framework',file_options=strongFileOptions,   force=False,  parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/CoreLocation.framework',file_options=strongFileOptions,   force=False,  parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/CoreTelephony.framework', force=False,  parent=frameworksGroupID,file_options=file_options,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/MediaPlayer.framework',  force=False, file_options=strongFileOptions,  parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/QuartzCore.framework', force=False, file_options=strongFileOptions,   parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/StoreKit.framework',  force=False, parent=frameworksGroupID,file_options=file_options,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/SystemConfiguration.framework',force=False,file_options=strongFileOptions,     parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/AdSupport.framework', force=False, file_options=strongFileOptions,   parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/Passkit.framework', force=False,  parent=frameworksGroupID,file_options=file_options,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/Mapkit.framework', force=False,  file_options=strongFileOptions,  parent=frameworksGroupID, tree='SDKROOT')
     project.add_file('System/Library/Frameworks/WebKit.framework', force=False, file_options=strongFileOptions,   parent=frameworksGroupID,tree='SDKROOT')
     project.add_file('System/Library/Frameworks/AVKit.framework',  force=False, parent=frameworksGroupID,file_options=file_options,tree='SDKROOT')  
Пример #7
0
 def add_Youmi(self):
     parent_path = os.path.dirname(self.xcodeProjectRootPath)
     sDKResourcePath= os.path.join(parent_path, 'sdks/Youmi')
     #库文件a
     file_options = FileOptions(weak=False,embed_framework=False,code_sign_on_copy=False)
     self.project.add_file(sDKResourcePath+'/libUMVideoSDK.a', force=False,  parent=self.frameworksGroupID,file_options=file_options,tree='SDKROOT')
     self.project.add_library_search_paths([sDKResourcePath],recursive=True)
     #资源文件.png
     self.project.add_file(sDKResourcePath+'/UMVideo.bundle', force=False,  parent=self.frameworksGroupID,file_options=file_options,tree='SDKROOT')
     pass
Пример #8
0
def _add(project, args):
    if '--header-scope' not in args or args['--header-scope'] not in [
            'public', 'private', 'project'
    ]:
        header_scope = 'project'
    else:
        header_scope = args['--header-scope']

    parent_group = None
    if args['--parent']:
        parent_group = project.get_or_create_group(args['--parent'])

    options = FileOptions(
        create_build_files=not args['--no-create-build-files'],
        weak=args['--weak'],
        ignore_unknown_type=args['--ignore-unknown-types'],
        embed_framework=not args['--no-embed'],
        code_sign_on_copy=args['--sign-on-copy'],
        header_scope=header_scope.title())
    build_files = project.add_file(args['<path>'],
                                   tree=args['--tree'],
                                   force=False,
                                   target_name=args['--target'],
                                   parent=parent_group,
                                   file_options=options)

    # print some information about the build files created.
    if build_files is None:
        raise Exception('No files were added to the project.')

    if not build_files:
        return 'File added to the project, no build file sections created.'

    info = {}
    for build_file in build_files:
        if build_file.isa not in info:
            info[build_file.isa] = 0
        info[build_file.isa] += 1

    summary = 'File added to the project.'
    for k in info:
        summary += f'\n{info[k]} {k} sections created.'
    return summary
def add_framework(project,
                  framework_path,
                  system_framework=False,
                  parent_dir_name='Custom Frameworks'):
    """
    Will add a framework to a project

    Args:
        project -> the xcode project
        framework_path -> the path to the framework (if it's a system framework, just set it's name, like: AudioToolbox.framework. Otherwise, specify full path to the .framework file)
        system_framework -> set this to true if the framework is a system one
        parent_dir_name -> if you set 'copy' to true, specify the name of the parent dir in the project to which the library will be copied
    """

    if _is_pods_system_framework(framework_path):
        raise RuntimeError(
            f'No need to append the pods framework {framework_path}!')
    if system_framework:
        framework_dst = f'{SYSTEM_FRAMEWORK_PREFIX}/{framework_path}'
    else:
        import os_file_handler.file_handler as fh
        framework_dir_name = fh.get_dir_name(framework_path)
        frameworks_parent = os.path.join(project._source_root, parent_dir_name)
        fh.create_dir(frameworks_parent)
        framework_dst = os.path.join(frameworks_parent, framework_dir_name)
        if not fh.is_dir_exists(framework_dst):
            fh.copy_dir(framework_path, framework_dst)

    frameworks_group = project.get_or_create_group('Frameworks')
    from pbxproj.pbxextensions.ProjectFiles import FileOptions
    file_options = FileOptions(weak=True, embed_framework=not system_framework)

    project.add_file(framework_dst,
                     parent=frameworks_group,
                     tree='SDKROOT',
                     force=False,
                     file_options=file_options)
Пример #10
0
def update_pbxproj(filename):
    # list all the compiled recipes
    ctx = Context()
    pbx_libraries = []
    pbx_frameworks = []
    frameworks = []
    libraries = []
    sources = []
    for recipe in Recipe.list_recipes():
        key = "{}.build_all".format(recipe)
        if key not in ctx.state:
            continue
        recipe = Recipe.get_recipe(recipe, ctx)
        recipe.init_with_ctx(ctx)
        pbx_frameworks.extend(recipe.pbx_frameworks)
        pbx_libraries.extend(recipe.pbx_libraries)
        libraries.extend(recipe.dist_libraries)
        frameworks.extend(recipe.frameworks)
        if recipe.sources:
            sources.append(recipe.name)

    pbx_frameworks = list(set(pbx_frameworks))
    pbx_libraries = list(set(pbx_libraries))
    libraries = list(set(libraries))

    print("-" * 70)
    print("The project need to have:")
    print("iOS Frameworks: {}".format(pbx_frameworks))
    print("iOS Libraries: {}".format(pbx_libraries))
    print("iOS local Frameworks: {}".format(frameworks))
    print("Libraries: {}".format(libraries))
    print("Sources to link: {}".format(sources))

    print("-" * 70)
    print("Analysis of {}".format(filename))

    project = XcodeProject.load(filename)
    sysroot = sh.xcrun("--sdk", "iphonesimulator", "--show-sdk-path").strip()

    group = project.get_or_create_group("Frameworks")
    g_classes = project.get_or_create_group("Classes")
    file_options = FileOptions(embed_framework=False, code_sign_on_copy=True)
    for framework in pbx_frameworks:
        framework_name = "{}.framework".format(framework)
        if framework_name in frameworks:
            print("Ensure {} is in the project (pbx_frameworks, local)".format(
                framework))
            f_path = join(ctx.dist_dir, "frameworks", framework_name)
        else:
            print(
                "Ensure {} is in the project (pbx_frameworks, system)".format(
                    framework))
            f_path = join(sysroot, "System", "Library", "Frameworks",
                          "{}.framework".format(framework))
        project.add_file(f_path,
                         parent=group,
                         tree="DEVELOPER_DIR",
                         force=False,
                         file_options=file_options)
    for library in pbx_libraries:
        print("Ensure {} is in the project (pbx_libraries, dylib+tbd)".format(
            library))
        f_path = join(sysroot, "usr", "lib", "{}.dylib".format(library))
        project.add_file(f_path,
                         parent=group,
                         tree="DEVELOPER_DIR",
                         force=False)
        f_path = join(sysroot, "usr", "lib", "{}.tbd".format(library))
        project.add_file(f_path,
                         parent=group,
                         tree="DEVELOPER_DIR",
                         force=False)
    for library in libraries:
        print("Ensure {} is in the project (libraries)".format(library))
        project.add_file(library, parent=group, force=False)
    for name in sources:
        print("Ensure {} sources are used".format(name))
        fn = join(ctx.dist_dir, "sources", name)
        project.add_folder(fn, parent=g_classes)

    project.backup()
    project.save()
Пример #11
0
 def updateProjectSetsForSDK(self,sdk_path):
     sdk_file_path=self.get_all_sdk_files(sdk_path)
     framework_search_path=[]
     library_search_path=[]
     header_search_path=[]
     for temp_path in sdk_file_path:
         if temp_path.endswith('bundle'):
             file_options = FileOptions(weak=False,embed_framework=False,code_sign_on_copy=False)
             self.project.add_file(temp_path, force=False,  parent=self.frameworksGroupID,file_options=file_options,tree='SDKROOT')
             pass
         elif temp_path.endswith('framework'):
             framework_search_path_temp=os.path.dirname(temp_path)
             if not framework_search_path_temp in framework_search_path:
                 framework_search_path.append(framework_search_path_temp)
             #库文件.framework
             mach_file_name=temp_path.split('/')[-1].split('.')[-2]
             file_path= os.path.join(temp_path,mach_file_name)
             #判断是否是动态库
             process=subprocess.Popen('file %s'%(file_path),shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
             (stdoutdata, stderrdata) = process.communicate()
             if 'dynamically' in stdoutdata:
                 embed_framework_val=True
                 code_sign_on_copy_val=True
             else:
                 embed_framework_val=False
                 code_sign_on_copy_val=False
             file_options = FileOptions(weak=False,embed_framework=embed_framework_val,code_sign_on_copy=code_sign_on_copy_val)
             self.project.add_file(temp_path, force=False,  parent=self.frameworksGroupID,file_options=file_options,tree='SDKROOT')
             pass
         elif temp_path.endswith('h'):
             header_search_path_temp=os.path.dirname(temp_path)
             if not header_search_path_temp in header_search_path:
                 header_search_path.append(header_search_path_temp)
             pass
         elif temp_path.endswith('m'):
             #
             strongFileOptions=FileOptions(weak=False,embed_framework=False,code_sign_on_copy=False)
             addFileReference= self.project.add_file(temp_path,  force=False,  file_options=strongFileOptions, parent=self.frameworksGroupID, tree='SDKROOT')
             #判断是否是非ARC编译,读取内容,看是否有....release]
             fin = open(temp_path,'r')
             result=None
             is_not_arc=False
             for eachLine in fin:
                 if 'release]'in eachLine:
                     is_not_arc=True
                     break
             fin.close()
             if is_not_arc==True:
                 files=self.project.get_build_files_for_file(addFileReference[0].fileRef)
                 for f in files:
                     f.add_compiler_flags('-fno-objc-arc')
             pass
         elif temp_path.endswith('a'):
             library_search_path_temp=os.path.dirname(temp_path)
             if not library_search_path_temp in library_search_path:
                 library_search_path.append(library_search_path_temp)
             file_options = FileOptions(weak=False,embed_framework=False,code_sign_on_copy=False)
             self.project.add_file(temp_path, force=False,  parent=self.frameworksGroupID,file_options=file_options,tree='SDKROOT')
             pass
         #图片等资源文件
         else:
             file_options = FileOptions(weak=False,embed_framework=False,code_sign_on_copy=False)
             self.project.add_file(temp_path, force=False,  parent=self.frameworksGroupID,file_options=file_options,tree='SDKROOT')
             pass
         pass
     for temp_path in framework_search_path:
         self.project.add_framework_search_paths([temp_path],recursive=True)
     for temp_path in library_search_path:
         self.project.add_library_search_paths([temp_path],recursive=True)
     for temp_path in header_search_path:
         self.project.add_header_search_paths([temp_path],recursive=True)
     self.addSystemFrameworkOrDylib(self.project)
     self.updateProjectSettings()
     self.project.save()
     pass
Пример #12
0
 def modifyXCodeFileCompilerFlag(self,filePath):
     strongFileOptions=FileOptions(weak=False,embed_framework=False,code_sign_on_copy=False)
     addFileReference= self.project.add_file(filePath,  force=False,  file_options=strongFileOptions, parent=self.frameworksGroupID, tree='SDKROOT')
     files=self.project.get_build_files_for_file(addFileReference[0].fileRef)
     for f in files:
         f.add_compiler_flags('-fno-objc-arc')