def change_bundle_id(filename, new_bundle_id): keyToModify = 'CFBundleIdentifier' plist = NSMutableDictionary.dictionaryWithContentsOfFile_(filename) if plist != None and keyToModify in plist.allKeys(): plist[keyToModify] = new_bundle_id plist.writeToFile_atomically_(filename, 1)
def get_version(self, dry=False): info = Folder(self.app.path).child('Contents/Info.plist') if not File(info).exists: self.fail("InfoPlist not found at :" + info) from Foundation import NSMutableDictionary plist = NSMutableDictionary.dictionaryWithContentsOfFile_(info) self.app.build_version = plist['CFBundleVersion'] self.app.marketing_version = plist.get('CFBundleShortVersionString', self.app.build_version)
def increment_release_version(filename, version): keyToModify = 'CFBundleVersion' plist = NSMutableDictionary.dictionaryWithContentsOfFile_(filename) if keyToModify in plist.allKeys(): versionString = plist[keyToModify] versionList = versionString.split(".") versionList.append(version) versionString = ".".join(versionList) plist[keyToModify] = versionString plist.writeToFile_atomically_(filename, 1) return versionString
def increment_development_version(filename, version): keyToModify = 'CFBundleShortVersionString' plist = NSMutableDictionary.dictionaryWithContentsOfFile_(filename) if keyToModify in plist.allKeys(): versionString = plist[keyToModify] versionList = versionString.split(".") lastVersionNumber = int(versionList[-1]) versionList.append(version) versionString = ".".join(versionList) plist[keyToModify] = versionString plist.writeToFile_atomically_(filename, 1) return versionString
def change_provisioning_profile(filename, build_conf_name, provisioning_profile): pbx_dict = NSMutableDictionary.dictionaryWithContentsOfFile_(filename) configurations = [x for x in pbx_dict['objects'] if pbx_dict['objects'][x]['isa'] == "XCBuildConfiguration" and pbx_dict['objects'][x]['name'] == "Release" and "PROVISIONING_PROFILE" in pbx_dict['objects'][x]['buildSettings'].allKeys()] profiles_to_replace = [] for config in configurations: profiles_to_replace.append(pbx_dict['objects'][config]['buildSettings']['PROVISIONING_PROFILE']) profiles_to_replace.append(pbx_dict['objects'][config]['buildSettings']['PROVISIONING_PROFILE[sdk=iphoneos*]']) for profile in profiles_to_replace: print "%s was replaced with %s in %s" % (profile, provisioning_profile, filename) replace(filename, profile, provisioning_profile)
def SetPlistKey(plist, key, value): """Sets the value for a given key in a plist. Args: plist: plist to operate on key: key to change value: value to set Returns: boolean: success Raises: MissingImportsError: if NSMutableDictionary is missing """ if NSMutableDictionary: mach_info = NSMutableDictionary.dictionaryWithContentsOfFile_(plist) if not mach_info: mach_info = NSMutableDictionary.alloc().init() mach_info[key] = value return mach_info.writeToFile_atomically_(plist, True) else: raise MissingImportsError('NSMutableDictionary not imported successfully.')
def SetPlistKey(plist, key, value): """Sets the value for a given key in a plist. Args: plist: plist to operate on key: key to change value: value to set Returns: boolean: success Raises: MissingImportsError: if NSMutableDictionary is missing """ if NSMutableDictionary: mach_info = NSMutableDictionary.dictionaryWithContentsOfFile_(plist) if not mach_info: mach_info = NSMutableDictionary.alloc().init() mach_info[key] = value return mach_info.writeToFile_atomically_(plist, True) else: raise MissingImportsError('NSMutableDictionary not imported successfully.')
def ModifyPlist( target_inf ): vardict = target_inf['vars'] filePath = vardict['xcodeplist_path'] print "\nModifying " + filePath plist = NSMutableDictionary.dictionaryWithContentsOfFile_( filePath ) plist['CFBundleDisplayName'] = vardict['name'] plist['CFBundleIdentifier'] = vardict['id'] plist['CFBundleVersion'] = vardict['version'] plist['CFBundleShortVersionString'] = vardict['major_version'] plist['UIViewControllerBasedStatusBarAppearance'] = False batch_config.ModifyPlist( plist, vardict['build_mode'] ) # save plist file plist.writeToFile_atomically_( filePath, 1 ) #print "-----------------------------------------------------------------" #os.system("cat " + filePath) #print "-----------------------------------------------------------------" return
pass from Foundation import NSMutableDictionary if os.environ["CONFIGURATION"] == "Development": status, output = commands.getstatusoutput("bash -l -c 'LANGUAGE=C svn info'") if status != 0: sys.exit(status) for line in output.split("\n"): if len(line.strip()) == 0 or ":" not in line: continue key, value = [x.lower().strip() for x in line.split(":", 1)] if key == "revision": revision = "svn" + value break else: revision = time.strftime("%Y%m%d") revision="1.0.0.20110909" buildDir = os.environ["BUILT_PRODUCTS_DIR"] infoFile = os.environ["INFOPLIST_PATH"] path = os.path.join(buildDir, infoFile) plist = NSMutableDictionary.dictionaryWithContentsOfFile_(path) version = open("version.txt").read().strip() % {"extra": revision} print "Updating versions:", infoFile, version plist["CFBundleShortVersionString"] = version plist["CFBundleGetInfoString"] = version plist["CFBundleVersion"] = version plist.writeToFile_atomically_(path, 1)
import os import csv from subprocess import Popen, PIPE from Foundation import NSMutableDictionary build_number = os.popen4("git rev-parse --short HEAD")[1].read() info_plist = os.environ['BUILT_PRODUCTS_DIR'] + "/" + os.environ[ 'WRAPPER_NAME'] + "/Info.plist" # Open the plist and write the short commit hash as the bundle version plist = NSMutableDictionary.dictionaryWithContentsOfFile_(info_plist) core_version = csv.reader([plist['CFBundleVersion'].rstrip()], delimiter=" ").next()[0] full_version = ''.join([core_version, ' build ', build_number]) plist['CFBundleVersion'] = full_version.rstrip() plist.writeToFile_atomically_(info_plist, 1)
from Foundation import NSMutableDictionary if os.environ["CONFIGURATION"] == "Development": status, output = commands.getstatusoutput( "bash -l -c 'LANGUAGE=C svn info'") if status != 0: sys.exit(status) for line in output.split("\n"): if len(line.strip()) == 0 or ":" not in line: continue key, value = [x.lower().strip() for x in line.split(":", 1)] if key == "revision": revision = "svn" + value break elif os.environ["CONFIGURATION"] == "Nightly": revision = time.strftime("%Y%m%d-nightly") else: revision = time.strftime("%Y%m%d") buildDir = os.environ["BUILT_PRODUCTS_DIR"] infoFile = os.environ["INFOPLIST_PATH"] path = os.path.join(buildDir, infoFile) plist = NSMutableDictionary.dictionaryWithContentsOfFile_(path) version = open("version.txt").read().strip() % {"extra": revision} print "Updating versions:", infoFile, version plist["CFBundleShortVersionString"] = version plist["CFBundleGetInfoString"] = version plist["CFBundleVersion"] = version plist.writeToFile_atomically_(path, 1)
elif opt in ("-t", "--plist-app-title"): PLIST_APP_TITLE = arg elif opt in ("-s", "--plist-app-subtitle"): PLIST_APP_SUBTITLE = arg elif opt in ("-n", "--plist-name"): PLIST_NAME = arg elif opt in ("-i", "--bundle-ident-suffix"): PLIST_BUNDLE_IDENTIFIER_SUFFIX = arg from Foundation import NSMutableDictionary from Foundation import NSMutableArray if not PLIST_APPLICATION_INFO_LOCATION: print '[ERROR] Cannot find plist file %(PLIST_APPLICATION_INFO_LOCATION)' sys.exit(1) application_info = NSMutableDictionary.dictionaryWithContentsOfFile_(PLIST_APPLICATION_INFO_LOCATION) PLIST_BUNDLE_IDENTIFIER = application_info.objectForKey_('CFBundleIdentifier') if PLIST_BUNDLE_IDENTIFIER_SUFFIX != '': PLIST_BUNDLE_IDENTIFIER = PLIST_BUNDLE_IDENTIFIER + PLIST_BUNDLE_IDENTIFIER_SUFFIX PLIST_BUNDLE_VERSION = application_info.objectForKey_('CFBundleVersion') print '[DEBUG] Bundle identifier = %(PLIST_BUNDLE_IDENTIFIER)s' % vars() print '[DEBUG] Bundle version = %(PLIST_BUNDLE_VERSION)s' % vars() root = NSMutableDictionary.dictionary() items = NSMutableArray.array() root.setObject_forKey_(items,'items') main_item = NSMutableDictionary.dictionary() items.addObject_(main_item) assets = NSMutableArray.array()