def update_xcode_project(xcodeproj, img_folder): pbxproj = os.path.join(xcodeproj, 'project.pbxproj') from mod_pbxproj import XcodeProject project = XcodeProject.Load(pbxproj) groups = project.get_groups_by_name('Images') if groups is None or len(groups) == 0: exit("XCode group named Images missing") if len(groups) > 1: exit("Too many groups named 'Images', so bailing'") group = groups[0] res_files = os.listdir(img_folder) for a_file in res_files: if a_file.startswith('.'): continue a_file_path = os.path.join(img_folder, a_file) res = project.add_file_if_doesnt_exist(a_file_path, group) if len(res) > 0: print('Adding new file - %s' % res) project.save()
def edit_unity_xcode_project(Log, unity_xcode_project_path, framework_path): # load unity iOS pbxproj project file unity_XcodeProject = XcodeProject.Load(unity_xcode_project_path) # Add adSupport framework to unity if it's not already there Log("Adding AdSupport.framework to Xcode project.") unity_XcodeProject.add_file_if_doesnt_exist(framework_path + "AdSupport.framework", tree="SDKROOT", create_build_files=True, weak=True) Log("AdSupport.framework successfully added.") # Add iAd framework to unity if it's not already there Log("Adding iAd.framework to Xcode project.") unity_XcodeProject.add_file_if_doesnt_exist(framework_path + "iAd.framework", tree="SDKROOT", create_build_files=True, weak=True) Log("iAd.framework successfully added.") # Removed. # Don't do anything with ARC at the moment. # # regex for adjust sdk files # re_adjust_files = re.compile(r"AI.*\.m|.*\+AI.*\.m|Adjust\.m|AdjustUnity\.mm") # # # Iterate all objects in the unity Xcode iOS project file # for key in unity_XcodeProject.get_ids(): # obj = unity_XcodeProject.get_obj(key) # # name = obj.get('name') # isa = obj.get('isa') # path = obj.get('path') # fileref = obj.get('fileRef') # # #Log("key: {0}, name: {1}, isa: {2}, path: {3}, fileref: {4}", key, name, isa, path, fileref) # # #check if file reference match any adjust file # adjust_file_match = re_adjust_files.match(name if name else "") # if (adjust_file_match): # #Log("file match, group: {0}", adjust_file_match.group()) # # get the build file, from the file reference id # build_files = unity_XcodeProject.get_build_files(key) # for build_file in build_files: # # add the ARC compiler flag to the adjust file if doesn't exist # build_file.add_compiler_flag('-fobjc-arc') # Log("added ARC flag to file {0}", name) # Add -ObjC to "Other Linker Flags" project settings. Log("Adding -ObjC to other linker flags.") unity_XcodeProject.add_other_ldflags('-ObjC') Log("Flag -ObjC successfully added.") # Save changes. unity_XcodeProject.save()
def fix_project(): project = XcodeProject.Load(prj_path + '/Unity-iPhone.xcodeproj/project.pbxproj') project.add_file_if_doesnt_exist('usr/lib/libc++.dylib', tree='SDKROOT') if project.modified: project.backup() project.save()
def testParsingPurePython(self): for file in [ 'music-cube', 'metal-image-processing', 'collection-view', 'cloud-search' ]: result = XcodeProject.Load('samples/{0}.pbxproj'.format(file), pure_python=True) control = osp.OpenStepDecoder.ParseFromFile( open('samples/{0}.pbxproj'.format(file))) assert result.data == control
def xcode_project_sync(file_path, xcode_group): if xcode_group == "": print( "INFO: not specify xcode group, so ignore sync imgs to Xcode project" ) return False ret = os.system("xcproj -h") print("ret", ret) if ret != 0: print( "please make sure xcproj tool installed. xcproj can make .pbxproj file look pretty" ) return False project_obj = XcodeProject.Load(project_file) modifyed = False for parent, dirnames, filenames in os.walk(file_path): xcode_path = xcode_group + parent[len(file_path):] group = xcode_get_or_create_group_by_path(project_obj, xcode_path) for f in filenames: if f.startswith("."): continue name = (parent + os.sep + f).decode("utf-8") if len( project_obj.get_files_by_name(f.decode("utf-8"), parent=group)) == 0: modifyed = True print("sync file to Xcode Group:%s" % name.encode("utf-8")) project_obj.add_file(name, parent=group) if modifyed: print("now save project file") project_obj.save() print( "success!\nAnd now use xcproj to retouch project, make it what it was" ) retouch_ret = os.system('xcproj -p "%s" touch' % project_file) if retouch_ret == 0: print("success!") else: print("some thing was error, call xproj failed.") return True else: return False
def __init__(self, projectRootPath=None): self.projectRootPath = projectRootPath projectName = os.path.basename(projectRootPath) self.pbxPath = os.path.join(projectRootPath, projectName + u".xcodeproj", u"project.pbxproj") self.project = XcodeProject.Load(self.pbxPath) self._shadowGroup = None self._sourceGroup = None self._frameworksGroup = None
def removeFile(): le = len(sys.argv) if le > 1: if "xcodeproj" not in sys.argv[1]: print "XProjRemoveFile: 无效的*.xcodeproj文件路径." else: if le > 2: pbx_path = sys.argv[1] + "/" + "project.pbxproj" project = XcodeProject.Load(pbx_path) for idx in range(2, le): project.remove_file_by_path(sys.argv[idx]) project.save() else: print "XProjRemoveFile: 没有传入需要移除的文件名称." else: print "XProjRemoveFile: 没有传入*.xcodeproj文件路径."
def addOtherFlags(): le = len(sys.argv) if le > 1: if "xcodeproj" not in sys.argv[1]: print "XProjAddOtherFlags: 无效的*.xcodeproj文件路径." else: if le > 2: pbx_path = sys.argv[1] + "/" + "project.pbxproj" project = XcodeProject.Load(pbx_path) for idx in range(2, le): project.add_other_ldflags(sys.argv[idx]) project.save() else: print "XProjAddOtherFlags: 没有传入Other Linker Flags参数." else: print "XProjAddOtherFlags: 没有传入*.xcodeproj文件路径."
def addGroup(): le = len(sys.argv) if le > 1: if "xcodeproj" not in sys.argv[1]: print "XProjAddGroup: 无效的*.xcodeproj文件路径." else: if le > 2: pbx_path = sys.argv[1] + "/" + "project.pbxproj" project = XcodeProject.Load(pbx_path) for idx in range(2, le): project.get_or_create_group(sys.argv[idx]) project.save() else: print "XProjAddGroup: 没有传入Group名称." else: print "XProjAddGroup: 没有传入*.xcodeproj文件路径."
def do_lint(pbxproj, is_strict, do_clean): logging.info('Analyzing: %s', pbxproj) project = XcodeProject.Load(pbxproj) errors, warnings = [], [] for es, ws in [ _lint_i18n(project, is_strict), _lint_files(pbxproj, project, do_clean) ]: errors.extend(es) warnings.extend(ws) for report, log_fn in [(errors, logging.error), (warnings, logging.warn)]: for _, msg in report: log_fn(msg) logging.info('Done. Errors: %d, Warnings: %d', len(errors), len(warnings)) if errors: sys.exit(1)
def ModifyXcodeProject( target_inf ): vardict = target_inf['vars'] filepath = vardict['xcode_pbxproj_path'] print "\nModifying " + filepath project = XcodeProject.Load( filepath ) batch_config.ModifyXcodeProject( project, vardict['build_mode'] ) if project.modified: project.backup() project.save() #print "-----------------------------------------------------------------" #os.system("cat " + filePath) #print "-----------------------------------------------------------------" return
def addBundle(): le = len(sys.argv) if le > 1: if "xcodeproj" not in sys.argv[1]: print "XProjAddBundle: 无效的*.xcodeproj文件路径." else: if le > 2: pbx_path = sys.argv[1] + "/" + "project.pbxproj" project = XcodeProject.Load(pbx_path) bundle_group = project.get_or_create_group(sys.argv[2]) for idx in range(3, le): project.add_file_if_doesnt_exist(sys.argv[idx], parent=bundle_group) project.save() else: print "XProjAddBundle: 没有传入Bundle路径." else: print "XProjAddBundle: 没有传入*.xcodeproj文件路径."
def edit_xcode_project(xcode_project_path): proc = Popen(["xcodebuild", "-version", "-sdk"], stdout=PIPE, stderr=PIPE) out, err = proc.communicate() if proc.returncode not in [0, 66]: Log("Could not retrieve Xcode sdk path. code: {0}, err: {1}", proc.returncode, err) return None match = re.search("iPhoneOS.*?Path: (?P<sdk_path>.*?)\n", out, re.DOTALL) xcode_sdk_path = match.group('sdk_path') if match else None Log("XCode SDK path: {0}", xcode_sdk_path) framework_path = xcode_sdk_path + "/System/Library/Frameworks/" Log("Framework path: {0}", framework_path) # Load iOS pbxproj project file. ios_XcodeProject = XcodeProject.Load(xcode_project_path) # Add adSupport framework. ios_XcodeProject.add_file_if_doesnt_exist(framework_path + "AdSupport.framework", tree="SDKROOT", create_build_files=True, weak=True) Log("Added adSupport framework") # Add iAd framework. ios_XcodeProject.add_file_if_doesnt_exist(framework_path + "iAd.framework", tree="SDKROOT", create_build_files=True, weak=True) Log("Added iAd framework") # Add Adjust framework. adjust_framework_path = os.path.dirname( os.path.abspath(__file__)) + "/adjust/sdk/ios/" ios_XcodeProject.add_file_if_doesnt_exist(adjust_framework_path + "Adjust.framework", tree="SDKROOT", create_build_files=True, weak=True) # Save changes. ios_XcodeProject.saveFormat3_2()
def addSysDylib(): le = len(sys.argv) if le > 1: if "xcodeproj" not in sys.argv[1]: print "XProjAddSysDylib: 无效的*.xcodeproj文件路径." else: if le > 2: pbx_path = sys.argv[1] + "/" + "project.pbxproj" project = XcodeProject.Load(pbx_path) root_path = 'usr/lib/' frameworks = project.get_or_create_group('Frameworks') for idx in range(2, le): project.add_file_if_doesnt_exist(root_path + sys.argv[idx], parent=frameworks) project.save() else: print "XProjAddSysDylib: 没有传入系统*.tbd或者*.dylib名称." else: print "XProjAddSysDylib: 没有传入*.xcodeproj文件路径."
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)) from mod_pbxproj import XcodeProject 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") for framework in pbx_frameworks: framework_name = "{}.framework".format(framework) if framework_name in frameworks: print("Ensure {} is in the project (local)".format(framework)) f_path = join(ctx.dist_dir, "frameworks", framework_name) else: print("Ensure {} is in the project (system)".format(framework)) f_path = join(sysroot, "System", "Library", "Frameworks", "{}.framework".format(framework)) project.add_file_if_doesnt_exist(f_path, parent=group, tree="DEVELOPER_DIR") for library in pbx_libraries: print("Ensure {} is in the project".format(library)) f_path = join(sysroot, "usr", "lib", "{}.dylib".format(library)) project.add_file_if_doesnt_exist(f_path, parent=group, tree="DEVELOPER_DIR") for library in libraries: print("Ensure {} is in the project".format(library)) project.add_file_if_doesnt_exist(library, parent=group) 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) if project.modified: project.backup() project.save()
return variant_group variant_group = PBXVariantGroup.Create(name) project.objects[variant_group.id] = variant_group parent_group.add_child(variant_group) build_file = PBXBuildFile.Create(variant_group) project.objects[build_file.id] = build_file phase.add_build_file(build_file) project.modified = True return variant_group if __name__ == "__main__": project = XcodeProject.Load("Client.xcodeproj/project.pbxproj") if not project: print "Can't open ", "Client.xcodeproj/project.pbxproj" sys.exit(1) for target_name in TARGETS.keys(): target = find_target(project, target_name) if not target: print "Can't find target ", target_name sys.exit(1) parent_group = find_group(project, target_name) if not parent_group: print "Can't find group ", target_name sys.exit(1)
#!/usr/bin/python import sys from mod_pbxproj import XcodeProject pathToProjectFile = sys.argv[1] + '/Unity-iPhone.xcodeproj/project.pbxproj' pathToNativeCodeFiles = sys.argv[2] project = XcodeProject.Load(pathToProjectFile) for obj in list(project.objects.values()): if 'path' in obj: if project.path_leaf('System/Library/Frameworks/AdSupport.framework' ) == project.path_leaf(obj.get('path')): project.remove_file(obj.id) if project.modified: project.save() project.add_folder(pathToNativeCodeFiles, excludes=["^.*\.meta$"]) project.add_file_if_doesnt_exist( 'System/Library/Frameworks/AdSupport.framework', tree='SDKROOT', weak=True, parent='Frameworks') project.add_file_if_doesnt_exist( 'System/Library/Frameworks/StoreKit.framework', tree='SDKROOT', parent='Frameworks') project.add_file_if_doesnt_exist('System/Library/Frameworks/WebKit.framework',
def main(): import argparse import os parser = argparse.ArgumentParser( "Modify an xcode project file using a single command at a time.") parser.add_argument('project', help="Project path") parser.add_argument('configuration', help="Modify the flags of the given configuration", choices=['Debug', 'Release', 'All']) parser.add_argument('-af', help='Add a flag value, in the format key=value', action='append') parser.add_argument('-rf', help='Remove a flag value, in the format key=value', action='append') parser.add_argument('-b', '--backup', help='Create a temporary backup before modify', action='store_true') parser.add_argument('-pp', '--pure-python', help='Use the pure python parser', action='store_true') args = parser.parse_args() # open the project file if os.path.isdir(args.project): args.project = args.project + "/project.pbxproj" if not os.path.isfile(args.project): raise Exception("Project File not found") project = XcodeProject.Load(args.project, pure_python=args.pure_python) backup_file = None if args.backup: backup_file = project.backup() # apply the commands # add flags if args.af: pairs = {} for flag in args.af: tokens = flag.split("=") pairs[tokens[0]] = tokens[1] project.add_flags(pairs, args.configuration) # remove flags if args.rf: pairs = {} for flag in args.rf: tokens = flag.split("=") pairs[tokens[0]] = tokens[1] project.remove_flags(pairs, args.configuration) # save the file project.save() # remove backup if everything was ok. if args.backup: os.remove(backup_file)
(XCODESUPPORTFOLDER, os.path.basename(shadowPath)), parent=shadowGroup) project.remove_file(os.path.relpath(sourcePath, projectBaseURL), parent=sourceGroup) project.save() if __name__ == '__main__': action = sys.argv[1] PBXProjectFilePath = sys.argv[2] shadowFilePath = sys.argv[3] sourceFilePath = sys.argv[4] projectBaseURL = sys.argv[5] project = XcodeProject.Load(PBXProjectFilePath) shadowGroup = project.get_or_create_group('Classes') sourceGroup = project.get_or_create_group('Sources') if "main.m" in shadowFilePath: sys.exit(0) files = project.get_files_by_os_path( "%s/%s" % (XCODESUPPORTFOLDER, os.path.basename(shadowFilePath))) if action == "add" and len(files) == 0: add_file(project, shadowGroup, sourceGroup, shadowFilePath, sourceFilePath, projectBaseURL) elif action == "remove" and len(files) == 1:
import argparse # Arguments are fun! parser = argparse.ArgumentParser() parser.add_argument("project", metavar='project', help='The xcodeproj to modify.') parser.add_argument('frameworks', metavar='frameworks', nargs='+', help='A set of .framework files to embed (specify the full path).') args = parser.parse_args() # Check if we can see a 'project.pbxproj' in the project directory if os.path.isfile(args.project + '/project.pbxproj') == False: print 'Error: ' + args.project + ' is not an xcodeproj.' sys.exit(-1) # Check that each framework is a directory for framework in args.frameworks: if os.path.isdir(framework) == False: print 'Error: ' + framework + ' does not exist.' sys.exit(-1) # Load the project using mod_pbxproj project = XcodeProject.Load(args.project + '/project.pbxproj') # Add each framework as a file for framework in args.frameworks: project.add_file_if_doesnt_exist(framework); # Embed each framework project.add_embed_binaries(args.frameworks) # Save our updated project file project.save()
flog('\n======== Add Other Linker Flags ========\n') for f in other_ldflags: project.add_other_ldflags(f) flog(f + ' \n') def change_buildsettings(project): flog('\n======== Change Build Settings ========\n') for s in build_settings: project.mod_buildSettings(s['key'], s['value']) flog(s['key'] + '=' + s['value'] + '\n') def save_project(project): project.saveFormat3_2() #### Script Start. #flog('Start of python script\n') flog('project path:\n' + projectPath + '\n') project = XcodeProject.Load(projectPath + '/project.pbxproj') add_frameworks(project) add_dylibs(project) add_other_ldflags(project) change_buildsettings(project) save_project(project) flog('\nAll done!\n') #### Script End.
if len(sys.argv) > 2: jsonFiles = list(sys.argv) del jsonFiles[0:2] else: jsonFiles = ["debug.json", "release.json"] print jsonFiles #create configuration objects dictOfConfig = dict() for file in jsonFiles: config = Configuration(file) dictOfConfig[config.name] = config #load project file and create a backup project = XcodeProject.Load(filePath) project.backup() rootObject = project["rootObject"] projectObject = project["objects"][rootObject]["buildConfigurationList"] for id in project["objects"][projectObject]["buildConfigurations"]: name = project["objects"][id]["name"].lower() #if this configuration need to be changed if dictOfConfig[name] is not None: entry = project["objects"][id]["buildSettings"] #for each setting in the json, apply to the target entry for key in dictOfConfig[name].jsonContent: entry[key] = dictOfConfig[name].jsonContent[key]
print("useICloudContainer: " + str(useICloudContainer)) print("useICloudKV: " + str(useICloudKV)) print("usePushNotifications: " + str(usePushNotifications)) # paths projectpath = projectname + '.xcodeproj/' projectfilename = 'project.pbxproj' backupPath = os.getcwd() + '/ProjectBackups/' plistPath = os.getcwd() + '/' + projectname + '/info.plist' altPlistPath = os.getcwd() + '/info.plist' entitlementsPath = os.getcwd( ) + '/' + projectname + '/' + projectname + '.entitlements' altEntitlementsPath = os.getcwd() + '/' + projectname + '.entitlements' # --- load the project file --- project = XcodeProject.Load(projectpath + projectfilename) # backup the project first print('Creating project backup') if not os.path.exists(backupPath): os.makedirs(backupPath) sourcePath = os.path.abspath(projectpath + projectfilename) destPath = backupPath + "%s.%s.backup" % ( projectfilename, datetime.datetime.now().strftime('%d%m%y-%H%M%S')) shutil.copy2(sourcePath, destPath) print('Cleaning unity export') # remove spil.framework from the data raw directory if it was exported by unity there project.remove_file_by_path('Frameworks/Plugins/iOS/Spil.framework') # remove any meta files if it was exported by unity for root, dirs, files in os.walk(os.getcwd() + "/Spil.framework"):
def modpbxproj(): from mod_pbxproj import XcodeProject, PBXBuildFile project = XcodeProject.Load(proj_file) if fabric_keys: project.add_run_script(target='Client', script='./Fabric.framework/run ' + fabric_keys[0] + ' ' + fabric_keys[1]) topgroup = project.get_or_create_group('brave', path='brave') group = project.get_or_create_group('src', path='brave/src', parent=topgroup) groups = {'brave/src': group} project.add_file('brave/Brave.entitlements', parent=topgroup, ignore_unknown_type=True) import os for root, subfolders, files in os.walk('src'): for folder in subfolders: g = project.get_or_create_group(folder, path='brave/' + root + '/' + folder, parent=group) groups['brave/' + root + '/' + folder] = g for file in files: if file.endswith('.h') or file.endswith('.js') or file.endswith('.swift') or file.endswith('.m') or file.endswith('.mm'): p = groups['brave/' + root] if 'test' in root: # add only to the test target project.add_file(file, parent=p, tree="<group>", target='ClientTests', ignore_unknown_type=True) continue build_files = project.add_file(file, parent=p, tree="<group>", target='Client', ignore_unknown_type=True) # This is the (crappy) method of listing files that aren't added to ClientTests filename_substrings_not_for_clienttest = ['Setting.swift'] if 'frontend' in root or 'page-hooks' in root or file.endswith('.js') or any(substring in file for substring in filename_substrings_not_for_clienttest): continue # from here on, add file to test target (this is in addition to the Client target) def add_build_file_to_target(file, target_name): target = project.get_target_by_name(target_name) phases = target.get('buildPhases') # phases = project.get_build_phases('PBXSourcesBuildPhase') find = phases[0] result = [p for p in project.objects.values() if p.id == find] list = result[0].data['files'] list.data.append(file.id) for b in build_files: if b['isa'] == 'PBXBuildFile': add_build_file_to_target(b, 'ClientTests') target_config_list = project.get_target_by_name('ClientTests').get('buildConfigurationList') configs = project.objects.data[target_config_list].data['buildConfigurations'].data for config_id in configs: config = project.objects.data[config_id] settings = config.data['buildSettings'].data settings['OTHER_SWIFT_FLAGS'] = '-D TEST -D BRAVE -D DEBUG' if not fabric_keys: settings['OTHER_SWIFT_FLAGS'] += " -D NO_FABRIC" group = project.get_or_create_group('abp-filter-parser-cpp', path='brave/node_modules/abp-filter-parser-cpp', parent=topgroup) for f in ['ABPFilterParser.h', 'ABPFilterParser.cpp', 'filter.cpp', 'node_modules/bloom-filter-cpp/BloomFilter.cpp', 'node_modules/bloom-filter-cpp/BloomFilter.h', 'node_modules/hashset-cpp/hashFn.h', 'node_modules/hashset-cpp/HashItem.h', 'node_modules/hashset-cpp/HashSet.h', 'node_modules/hashset-cpp/HashSet.cpp', 'cosmeticFilter.h', 'cosmeticFilter.cpp']: project.add_file(f, parent=group, tree="<group>", target='Client', ignore_unknown_type=True) group = project.get_or_create_group('tracking-protection', path='brave/node_modules/tracking-protection', parent=topgroup) for f in ['FirstPartyHost.h', 'TPParser.h', 'TPParser.cpp']: project.add_file(f, parent=group, tree="<group>", target='Client', ignore_unknown_type=True) arr = project.root_group.data['children'].data arr.insert(0, arr.pop()) if fabric_keys: project.add_file('Fabric.framework', target='Client') project.add_file('Crashlytics.framework', target='Client') configs = [p for p in project.objects.values() if p.get('isa') == 'XCBuildConfiguration'] for i in configs: build_settings = i.data['buildSettings'] if 'PRODUCT_BUNDLE_IDENTIFIER' in build_settings: if 'PRODUCT_NAME' in build_settings and 'Client' in build_settings['PRODUCT_NAME']: build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = 'com.brave.ios.browser' else: build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = 'com.brave.ios.browser.$(PRODUCT_NAME)' elif 'INFOPLIST_FILE' in build_settings: build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = 'com.brave.ios.browser.$(PRODUCT_NAME)' project.save()
import sys import os project_name = None source_dir = sys.argv[1] req_file = sys.argv[2] for word in os.listdir(source_dir): if word.endswith(".xcodeproj"): project_name = word print("ProjectName:" + project_name) pbx_proj = sys.argv[1] + "/" + project_name + "/project.pbxproj" print("Pbxproject:" + pbx_proj) from mod_pbxproj import XcodeProject project = XcodeProject.Load(pbx_proj) project_name_new = project_name[:-10] new_group = project.get_or_create_group(project_name_new) project.add_folder(req_file, parent=new_group) targets = project.get_targets() main_target = project.get_obj(targets[0]) main_source = project.get_obj(main_target['buildPhases'][0]) main_files = main_source['files'] i = 1 result = None while i < len(targets): target = project.get_obj(targets[i]) source = project.get_obj(target['buildPhases'][0])
import os if __name__ == '__main__': from mod_pbxproj import XcodeProject # open the project project = XcodeProject.Load('nestopia_xcode.xcodeproj/project.pbxproj') with open("./cpp.txt") as fp: lines = fp.readlines() for line in lines: line = "../" + line.strip() _path, _file = os.path.split(line) _filename2, _ext = os.path.splitext(_file) _filename = _filename2.replace("nestopia-", "") # print _path for ext in [".cpp", ".hpp", ".inl"]: dist = os.path.join(_path, _filename + ext) # print dist if os.path.exists(dist): # print dist # project.remove_file_by_path( dist ) group = project.get_or_create_group(_path[3:]) project.add_file_if_doesnt_exist(dist, parent=group) pass # save the project, otherwise your changes won't be picked up by Xcode project.save()
def modifyBitcode(path, enable='NO'): project = XcodeProject.Load(path) project.add_single_valued_flag('ENABLE_BITCODE', enable) project.save()
return [] extension = extension.lower() file_list = os.listdir(path) # make sure they get processed in alpha order file_list.sort() return [ os.path.join(path, f) for f in file_list if os.path.splitext(f)[1].lower() == extension ] #xcode project project = XcodeProject.Load(sys.argv[1] + '/Unity-iPhone.xcodeproj/project.pbxproj') #directory where .projmods are package_path = sys.argv[2] #find all .projmods #mods = find_files(package_path, '.projmods') #mods.extend(find_files(plugin_path, '.projmods')) mods = [] for root, dirnames, filenames in os.walk(package_path): for filename in fnmatch.filter(filenames, '*.projmods'): mods.append(os.path.join(root, filename)) #apply each .projmod to the project
import os import re from sys import argv from mod_pbxproj import XcodeProject path = argv[1] print path project = XcodeProject.Load(path + '/Unity-iPhone.xcodeproj/project.pbxproj') project.add_file_if_doesnt_exist( 'System/Library/Frameworks/Security.framework', tree='SDKROOT') project.add_file_if_doesnt_exist('usr/lib/libicucore.dylib', tree='SDKROOT') # regex for adjust sdk files re_adjust_files = re.compile(r"SRWebSocket\.m") # iterate all objects in the unity Xcode iOS project file for key in project.get_ids(): obj = project.get_obj(key) name = obj.get('name') adjust_file_match = re_adjust_files.match(name if name else "") if (adjust_file_match): build_files = project.get_build_files(key) for build_file in build_files: # add the ARC compiler flag to the adjust file if doesn't exist build_file.add_compiler_flag('-fobjc-arc')
if not os.path.exists(xcode_project_path): print("Error: could not find PocketCampus Xcode project.") exit(-1) xcode_project_path = os.path.abspath(xcode_project_path) pbxproj_path = os.path.join(xcode_project_path, "PocketCampus.xcodeproj", "project.pbxproj") # # Add plugin to Xcode project # plugin_folder_name = os.path.basename(plugin_folder_path) project = XcodeProject.Load(pbxproj_path) plugins_group = project.get_or_create_group('Plugins') #Do not add lproj folders because they would not be reconized as localized files project.add_folder(plugin_folder_path, parent=plugins_group, excludes=["^.*\.lproj$", "^.*\.strings$"]) plugin_group = project.get_or_create_group(plugin_folder_name, parent=plugins_group) supporting_files_group = project.get_or_create_group('Supporting Files', parent=plugin_group) strings_files = []