IOS Bulk Pack--shell scripts

Source: Internet
Author: User

Because the company has the need of bulk packaging, but the channel number is not the same, online search, there are roughly two ways: a) from the source program all channels of the IPA package, the idea is to use a script loop to carry out the packaging process, And each time before packaging through the script to modify the project to hold the channel number file is the current cycle of the latest channel number, let the after packaging. b) provide an IPA format for the parent package to generate all the other channel packages from the parent package, you may ask: Is it possible to generate additional packages with one package?
The reason is this: Because each channel is only the channel number changes, and the other content does not change, And our channel number is stored in info.plist this file, so as long as the content of the Info.plist file in the parent package can be changed, and the IPA package is also compressed with the ZIP format, so the basic idea is to unpack the parent package by Zip, and then change the contents of Info.plist Finally, zip compression into the corresponding channel package can be.

By making packages from the parent package to other channels this approach: get the following benefits

I. Reduce the workload of Rd, QA.

II. The risk of testing the release process is under control.

III. Improved packaging release efficiency. (Dozens of packs in just a few minutes).

Iv. improved automation.

V. Do not rely on Mac and Xcode environment directly under Linux to complete the generation of other packages from the parent package

The specific code is as follows: (You can create a. sh file with Xcode)

#!/bin/sh

config_root_path="/users/hezhujin/desktop/"#.ipa the path of the parent package

CD $CONFIG _root_path

Sourceipaname="Wgc_ios.ipa" #ipa The name of the mother bag

appname= "Wgc_ios.app"         # Payload catalog item . App

distdir="/users/hezhujin/desktop/qa" # file storage directory after packing

RM-RDF "$distDir"

mkdir "$distDir"

Unzip $sourceipaname # unzip the master package file

for ((i=1001;i<1011; i++))

Do

CD Payload

CD $appname

Targetname="Wgc_ios"

/usr/libexec/plistbuddy-c "Set:kchannelnumber ${i}" info.plist # Modify the Kchannelnumber corresponding value ofthe info.plist file , the info.plist must first exist this Key to modify

Cd.. /..

zip-r "${targetname}_${i}.ipa" Payload # make a bundle of other channels

mv "${targetname}_${i}.ipa" $distDir # Move the package to the target path

Done

RM-RDF Payload

You can simply drag the edited script.sh file onto the terminal to enter or terminal input./script.sh

You can perform chmod 777 if you encounter permissions issues script.sh

The following is a non-incrementing form of the channel number specified in the array form

#!/bin/sh

config_root_path= "/users/hezhujin/desktop/"

CD $CONFIG _root_path

Sourceipaname="Wgc_ios.ipa"

appname= "Wgc_ios.app" # pauload directory entry after pressurization . App file name needs to be modified according to your own project

distdir="/users/hezhujin/desktop/qa" # file storage directory after packing

RM-RDF "$distDir"

mkdir "$distDir"

Unzip $sourceipaname # unzip the master package file

Kchannelnumber= ("AAA " " bbb " "CCC")

for ((i=0; i<${#kChannelNumber};i++))

Do

CD Payload

CD $appname

ipafilename=${kchannelnumber[$i]}

Targetname="Wgc_ios"

/usr/libexec/plistbuddy-c "Set:kchannelnumber ${kchannelnumber[$i]}" Info.plist

Cd.. /..

zip-r "${targetname}_${ipafilename}.ipa" Payload # make a bundle of other channels

mv "${targetname}_${ipafilename}.ipa" $distDir

Done

RM-RDF Payload

The following are not recommended methods: Each package is a recompile method

#!/bin/sh

# script.sh

# Shell

#

# Created by Hezhujin on 15/3/4.

# Copyright (c) year Hezhujin. All rights reserved.

#!/bin/sh

config_root_path="/users/hezhujin/desktop/wgc_ios"

CD $CONFIG _root_path

# Number of loops

Channelid= ("AA" "BB" "CC")

for ((i=0; i<${#CHANNELID};i++))

Do

# Delete

rm-rf "/users/hezhujin/desktop/wgc_ios/build/"

# Clear

Xcodebuild-target Wgc_ios Clean

# Modify plist

/usr/libexec/plistbuddy-c "Set:channelid ${channelid[$i]}" /users/hezhujin/desktop/wgc_ios/wgc_ios/ Info.plist

#/usr/libexec/plistbuddy-c "Set:cfbundleshortversionstring 1.0.4"/users/hezhujin/desktop/wgc_ios/wgc_ios/ Info.plist

# Pack

Xcodebuild-target wgc_ios-configuration distribution-sdk Iphoneos Build

# Generate IPA

xcrun-sdk iphoneos packageapplication-v "/users/hezhujin/desktop/wgc_ios/build/release-iphoneos/wgc_ Ios.app "- o "/users/hezhujin/desktop/wgc_ios/wgc_ios_${channelid[$i]}.ipa "

Done

IOS Bulk Pack--shell scripts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.