Introduction to "IOS" automation packaging

Source: Internet
Author: User

Summary

With the growing number of Apple handheld devices, iOS apps are growing fast, and as the iphone gets more and more apps are being jailbroken, it's a time-consuming task to package each channel, and this article provides a smarter way to pack and reduce the inconvenience.

TAG

iOS pack, App Pack, iphone pack, iphone Automation pack, iOS Channel pack, iphone automation channel Pack

Automated Packaging Background Introduction

1. Background

As iOS programs release more and more channels, packaging for each channel becomes a particularly time-consuming and physical technique, most of which is done by Rd. This takes a lot of RD development time, why not write these things into an automated script, and then hand it over to QA or PM to complete the packaging process. After some research, this kind of script is still very small, but Xcode provides shell compiler tool xcodebuild and IPA Packaging tool Xcrun, which makes it reasonable for us to use these two tools to write an automated packaging script to improve our productivity and automation level.

2. ios package format, channel package format

1) The causes of multi-channel and multi-channel packaging problems: With the iphone, ipad, itouch and other handheld devices sold hot, and their applications are also hot up, and the resulting is that the above devices are jailbroken after the jailbreak device can run directly on the IPA package Instead of downloading through AppStore, the country has produced a number of channels dedicated to jailbreak mobile phones to provide an IPA package download. As more and more channels are being packaged for each channel, it becomes a time-consuming and energy-intensive technology, so we must look for an automated way to make packaging efficient and simple.
2) iOS package is divided into two formats AppStore binary file and channel package
AppStore binaries: The Xcode tool allows you to generate a. App-formatted binary file.
Channel package: In the format. IPA format, before the automated packaging tools are used to generate the appropriate channel package, and only one channel package can be generated at a time, each time the packaging before the manual of the channel ID, the problem is time-consuming, inefficient, error-prone, increased risk.

3. Traditional iOS Packaging method

Package with Xcode

1) AppStore binary Package
Open your project, go to "Edit project Settings", go to the Configuration page, select release click on the duplicate below, copy a new configuration item, named distribution. Then go to the Build page, the top Configuration drop-down box selected distribution, the following code Signing identity inside any iPhone OS The corresponding value after the device selects your distribution certificate. Then click "Build" –< "build" to compile the program.
Once the compilation is successful, you will be able to see a. App binary file in the appropriate build directory.
2) Channel IPA package
Follow the steps above to configure the distribution certificate, then click "Build" –< "Build and Archive" to compile the program. Then open "window"? " Organizer "Choose archived applications in the left column and then select the package you just compiled in the right-hand list and click on the" Share "button at the top right-hand side to save to disk. A. IPA file is generated as a channel bundle.
Note: The above operating device must select "Deveice"

4, the traditional packaging brings problems

Time consuming, energy consuming, inefficient, can only rely on rd to complete, error prone, release risk is relatively high, QA regression confirmation is more difficult, not intelligent.

Automated packaging specific implementations

1, Xcodebuild Introduction:
1    xcodebuild[-Project2    ][-activetarget][-alltargets][-target] ... [-parallelizetargets] [-activeconfiguration] [-configuration] [-SDK |] [=]... []... 3    XCODEBUILD[-VERSION[-SDK |] 4    xcodebuild[-Showsdks]5    xcodebuild[-find][-sdk |] 6    Xcodebuild[-list]

You can also view specific options in Terminal input: Xcodebuild–help or –h
Show Xcodebuildversion:xcodebuild–version
Displays the Sdk:xcodebuild–showsdks of the current system installation
Displays the current directory under Project Information:xcodebuild–list
Note that you must locate the location in the root directory of the iOS project file if you execute the above command, or you will be prompted for an unrelated command.

2, Xcrun Introduction:

This tool is primarily used to package app files into an IPA-formatted package. (mainly used for jailbroken mobile phones).
The specific usage is as follows:

1    /USR/BIN/XCRUN-SDK Iphoneos Packageapplication–v[{target}.app]-o [{Target}.ipa]--sign [{Iphone distribution:xxx}]– Embed [{xxx.mobileprovision}]

Where:-V corresponds to the absolute relative path of the app file –o the path to the IPA file and the filename –sign
corresponding to the corresponding company name or personal name in the certificate of publication –embed corresponding to the publishing certificate file
Note If the relevant certificate information is already configured in the corresponding distribution configuration, –sign and –embed can be ignored

3, the specific plan

A) from the source program all channels of the IPA package with AppStore binary package
In order for the automation script to be executed once all the channel package is good, so there must be a configuration file to store all channel name and channel number, and the project file should also have a corresponding to store the current channel number of the file, each time the program from the file to store channel number to read the channel number can be, The general idea is to use a script loop to carry out the packaging process, and each time before packaging through a script to modify the project to hold the channel number file is the current cycle of the latest channel number, let the later packaging.
Note: See Appendix for specific examples
b) provide an IPA-format master package to generate all other channel packages and AppStore packets from the parent package
QA questions, how do you make sure that all the channel packs are the code they've verified?
Indeed, each time the above code is to re-package the program, QA can often test the verification of only one package, if all to verify inadvertently added to the workload of the QA ha!! And the risks are not manageable. So based on the above question we came up with a way: QA verifies only one package (that is, the parent package) if the package by verifying that we go through the parent package to generate other channels of the package, so that QA does not have to confirm so many channel package, the risk has been effectively controlled.
Perhaps you would ask: Is it possible to generate other 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 Sourceid.dat this file, so as long as the content of the Sourceid.dat 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 Sourceid.dat Finally, zip compression into the corresponding channel package can be.
Directory of IPA packages:
Note: See Appendix for specific examples

Some questions

When some shell commands do not pass through the Mac's terminal, make sure your shell scripts are written in a Mac environment instead of being copied from other environments such as XP. Because Mac and XP code is not the same, so there will be problems.

Summarize:

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

I. Reduce the workload of Rd, together with the workload of 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

Appendix

Use the Xcode environment to generate shell script code for all packages at once:
 on#!/bin/SH Geneva     GenevaXcodebuild clean-configuration Distribution//Clean ProjectGeneva      toDistdir="/users/xxxx/dist" .Releasedir="Build/distribution-iphoneos" -version="1_0_0" ,Rm-rdf"$distDir" theMkdir"$distDir"TenForlineinch$ (Catdata.dat)//Read all channel numbers data.dat files One     Do AIpafilename= ' echo$line|cut-f1-d':'`//Channel name -Sourceid= ' echo$line|cut-f2-d':'`//Channel number -Echo"ipafilename= $ipaname" theEcho"sourceid= $sourceid" -Targetname="Youtargename"//Project name (the project name shown in the list on the left of Xcode) -Echo"sourceid= $sourceid" -Echo"ipafilename= $ipafilename" +Echo"$sourceid"<Sourceid.dat -Echo"Sourceid.dat:" +Catsourceid.dat ARm-rdf"$releaseDir" at      -Ipapath="${distdir}/${targetname}_${version}_from_${sourceid}.ipa" -      -Echo"* * * Start build App file * * *" -Xcodebuild-target"$targetName"-configuration Distribution-SDK Iphoneos Build -appfile="${releasedir}/${targetname}.app" in    if[$sourceid = ="AppStore"] - Then toCd$releasedir +Zip-r"${targetname}_${ipafilename}_${version}.zip""${targetname}.app" -Mv"${targetname}_${ipafilename}.zip"$distDir2</dev/NULL theCd.. /.. *    Else $Echo"* * * start playing IPA Channel package * * *"Panax Notoginseng/USR/BIN/XCRUN-SDK Iphoneos Packageapplication-v"$appfile"-O"$ipapath"--sign"IPhone distribution:xxxxxx" -fi theDone

Note: The above Data.dat file is the file that holds the channel number list in the format: 3g:1001b (channel name: Channel number) Sourceid.dat the file for the channel number in the project file (the content has only one channel number). Of course, the script above just shows how to use Xcodebuild and Xcrun for packaging and automatic packaging of a logic, shell script good classmate can free play ha ...

Generate shell script instances for other channel packages from the parent package in IPA format:
 on#!/bin/SH GenevaSourceipaname="The name of the parent package. IPA"GenevaAppname= "app filename. App"//pauload directory entry after pressurization. app file name needs to be modified according to your own projectGenevaDistdir="/users/lxxx/qa"//file storage directory after packaging toversion="1.0.0" .Rm-rdf"$distDir" -Mkdir"$distDir"Unzip $sourceipaname//Unzip the master package file ,Forlineinch$ (Catdata.dat)//read the channel number file and loop the     DoTenIpafilename= ' echo$line|cut-f1-d':'` OneSourceid= ' echo$line|cut-f2-d':'` AEcho"ipafilename= $ipaname" -Echo"sourceid= $sourceid" -Targetname="IPA package Name" theEcho"sourceid= $sourceid" -Echo"ipafilename= $ipafilename" -Cdpayload -Cd$appname +Echo"replace Sourceid.dat before:" -Catsourceid.dat +Echo"$sourceid"<Sourceid.dat AEcho"replace Sourceid.dat after:" atCatsourceid.dat -    if[$sourceid = ="Appstroe"] - Then -CD.. -Zip-r"${targetname}_${version}_from_${sourceid}.zip"$appname//AppStore binary Files -      inMv"${targetname}_${version}_from_${sourceid}.zip"$distDir -CD.. to    Else +Cd.. /.. -Zip-r"${targetname}_${version}_from_${sourceid}.ipa"Payload//into other channels of the package theMv"${targetname}_${version}_from_${sourceid}.ipa"$distDir *fi $DONERM-RDF Payload

Note: The above data.dat is also used to store all channel numbers, Sourceipaname is through the QA verification of the master package, appname for the IPA package after pressurization payload The app file name under the directory and all of the above files must be kept in the same directory as the script file and executed in the MAC environment.

Introduction to "IOS" automation packaging

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.