## Automatic packaging is divided into two parts

– Generate an archive file – Export the IPA package from the archive file

The xcodebuild command is used to generate the archive package

For a normal project command:

Xcodebuild archive -project Project name XcodeProj – Scheme Application name – Configuration Configuration -archivePath Desired saving path xcodeProj – Scheme Application name – Configuration Configuration -archivePath

For workspace the command is

Xcodebuild archive – Name of the workspace xcworkspace -scheme Application name – Configuration Configuration -archivePath Desired path

ExportOptionPlist is packaged configuration information (such as whether bitecode is supported, certificates and description files…..) About the following

There is no automatic generation of this in my script, my suggestion is to package it manually and then find the file in the package and save it for good

After the Archive file is successfully generated, the IPA package must be exported from it

Xcodebuild -exportArchive -archivePath archive File path -exportPath Expected path for saving after packaging -exportOptionsPlist PlIST file for exporting configuration information

## Upload to dandelion according to dandelion documentation API2.0 command line as follows

Curl -f ‘file = @ the path of ipa package – F’ _api_key = dandelion AppKey provided by https://www.pgyer.com/apiv2/app/upload

### After knowing the steps, the script just needs to combine these command lines and insert its own operations, such as notifications to testers, output of current status, and so on…. (I didn’t need this piece, so I didn’t write it.)

And then I’m going to add the code because it’s not long and I’m going to write it right here

#! The/usr/bin/env python3 import OS # # # # # # # # # # # # # # # # # # # # # # # to user configuration # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # will be on the new version described updateDescription = "# projectPath projectPath =" # projectName projectName = "# package path IPASavePath =" # exportOptionPlist file path ExportOptionPlistPath = "# pgy_appKey =" # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # generated Archive file path archivePath = IPASavePath + '/' +projectName + 'Archive' IpaPath = IPASavePath + '/Apps/' +projectName + '.ipa' # def clearScreen(): Os. system('clear') os.chdir(projectPath) # def makeArchive(): os.system('xcodebuild archive -workspace %s.xcworkspace -scheme %s -configuration Release -archivePath % s' % (projectName, projectName archivePath)) # generate iPa package def makeIpa () : os.system('xcodebuild -exportArchive -archivePath %s.xcarchive -exportPath %s -exportOptionsPlist % s' % (archivePath, IPASavePath exportOptionPlistPath)) # uploaded to the dandelion def upLoadToPGYer () : res = (os.popen("curl -F 'file=@%s' -F '_api_key=%s' -F'updateDescription=%s' https://www.pgyer.com/apiv2/app/upload "% (IpaPath pgy_appKey, updateDescription))). The readlines () # automatic packing def automaticPack () : clearScreen() makeArchive() makeIpa() upLoadToPGYer() automaticPack()Copy the code