每隔一两周就要导出ipa一次,所以制作了一个python脚本。
#!usr/bin/env python
# -*- coding:utf-8 -*-
import os
from subprocess import check_call as call
from subprocess import CalledProcessError as CalledProcessError
def main():
APP_NAME = 'HuaWeiRemoteCtl'
IPA = '%s.ipa' % APP_NAME
# step 1: remove old .ipa file
if os.path.exists(IPA):
os.remove(IPA)
try:
# step 2: build project to archive
cmd = ['xcodebuild', 'archive']
cmd.extend(['-project', APP_NAME + '.xcodeproj'])
cmd.extend(['-scheme', APP_NAME])
cmd.extend(['-archivePath', APP_NAME + '.xcarchive'])
call(cmd)
# step 3: export to .ipa from archive
cmd = ['xcodebuild', '-exportArchive']
cmd.extend(['-archivePath', APP_NAME + '.xcarchive'])
cmd.extend(['-exportPath', APP_NAME) # full path filename
cmd.extend(['-exportFormat', 'ipa'])
cmd.extend(['-exportProvisioningProfile', 'iOS Team Provisioning Profile: my.company.HuaWeiRemoteCtl'])
call(cmd)
except CalledProcessError:
print('error!')
if __name__ == '__main__':
main()
其中,第三步的 provisioning profile 值,是从Xcode IDE里取出来的,如下图: