IPhone packaging procedure

Source: Internet
Author: User
Xcodebuild and xcrun automatically package IOS apps 20:30:07 Source: Baidu search R & D department Author:

As the number of users of Apple handheld devices increases, IOS applications also increase rapidly. As the number of iPhone jailbroken apps increases, packaging for various channels is time-consuming and labor-consuming. This article provides a more intelligent packaging method to reduce the inconvenience it brings.

As the number of users of Apple handheld devices increases, IOS applications also increase rapidly. As the number of iPhone jailbroken apps increases, packaging for various channels is time-consuming and labor-consuming. This article provides a more intelligent packaging method to reduce the inconvenience it brings.

Automated packaging Background 1. Background

With the increasing number of channels for iOS program release, packaging for each channel has become a technical activity that takes a lot of time and effort, and most of this is done by RD. This takes a lot of time for RD development. 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, we found that there are few such scripts on the Internet, but xcode provides the shell compilation tool xcodebuild and IPA packaging tool xcrun, there is a reason for us to use these two tools to write an automated packaging script to improve our work efficiency and automation.

2. iOS package format and channel package format

1) Reasons for multi-channel production and packaging problems brought about by multiple channels: As handheld devices such as iPhone, iPad, and itouch are selling hot, their applications are also booming, then, after the above devices are jailbroken, they can directly run the IPA package on the jailbroken device instead of downloading it through the appstore, in this way, many channels dedicated to jailbreak mobile phones have been created in China to provide download of IPA packages. As more and more channels are available, packaging for various channels becomes a time-and energy-consuming technical activity. Therefore, we must find an automated way to make packaging more efficient and simple.
2) iOS packages are classified into two formats: appstore binary files and channel packages.
Appstore binary file: You can use xcode to generate a. app binary file.
Channel package: Format. IPA format. xcode is used to generate the corresponding channel package before automatic packaging tools are available, and only one channel package can be generated at a time. You must manually specify the channel ID before packaging, the problems are time-consuming, inefficient, error-prone, and increased risks.

3. Traditional IOS packaging methods

Use xcode to package

1) appstore Binary Package
Open your project, go to "Edit Project Settings", go to the configuration page, select release and click duplicate, copy a new configuration item, and name it distribution. Then go to the build page, and select distribution in the configuration drop-down box on the top. Any in the code signing identity below

Select your Distribution Certificate for the value next to the iPhone OS device. Click "build"-> "build" to compile the program.
After the compilation is successful, you can see a. app binary file in the corresponding build directory.

2) channel IPA package
Configure the distribution certificate according to the above steps, and then click "build"-> "Build and archive" to compile the program. Next, open "window" "organizer", select "archived Applications" on the Left bar, select the compiled package from the list on the right, and click "share" on the top right to save the package to the disk.. A. IPA file is generated as a channel package.
Note: The above running device must select "deveice"

4. Traditional Packaging Problems

Time-consuming, manual, low-efficiency, only RD-dependent, error-prone, high release risks, difficulty in QA regression validation, and inintelligence.

Automated packaging specific implementation of C/C ++ code copying content to the clipboard
  1. Xcodebuild [-project] [-activetarget] [-alltargets] [-target]... [-parallpolicetargets] [-activeconfiguration] [-configuration] [-SDK |] [=]... []...
  2. Xcodebuild [-version [-SDK |]
  3. Xcodebuild [-showsdks]
  4. Xcodebuild [-find] [-SDK |]
  5. Xcodebuild [-list]

 

1. xcodebuild introduction:

You can also enter xcodebuild-help or-H on the terminal to view the specific options.
Show xcodebuildversion: xcodebuild-version
Show the sdks installed in the current system: xcodebuild-showsdks
Display project information: xcodebuild-list in the current directory
Note: When executing the preceding commands, you must locate them in the root directory of the IOS project file. Otherwise, you will be prompted to find irrelevant commands.

2. xcrun introduction:

This tool is mainly used to package an app file into an IPA package. (Mainly used for jailbroken mobile phones ).
The usage is as follows:

Where:-V corresponds to the absolute relative path of the app file-O corresponds to the path of the IPA file and the file name-sign
The corresponding company name or personal name-embed in the publishing certificate corresponds to the publishing Certificate file
Note: If the certificate information is configured in the corresponding distribution configuration,-sign and-embed can be ignored.

3. Specific solutions

A) the IPA package and appstore Binary Package of all channels are output from the source program at a time.
To enable automatic script execution to lay all channel packages at a time, you must have a configuration file to store all channel names and channel numbers, the project file should also have a file that stores the current channel number. Every time the program reads the channel number from the file that stores the channel number, the general idea is to use the script to execute the packaging process cyclically. Before each package, use the script to change the file storing the channel number in the project to the latest Channel Number of the current loop, and then package it one by one.
Note: For specific examples, see the appendix.
B) Provide an IPA parent package to generate all other channel packages and appstore packages from the parent package
Some QA questions: how can we ensure that all channel packages are the code they have verified?
Indeed, the above Code is re-packaged for the program each time. QA usually only has one package for testing and verification. If all the packages are verified, the QA workload is inadvertently increased !! And the risks are uncontrollable. Therefore, based on the above problem, we have come up with a solution: QA only verifies one package (that is, the parent Package). If this package passes verification, we generate packages from other channels through the parent package, in this way, QA does not need to identify so many channel packages, and the risks are effectively controlled.
Maybe you will ask: is it feasible to generate other packages with one package ??
The reason is: because each channel only has a channel number change, and other content does not change, and our channel number is stored in sourceid. in the DAT file, you only need to change the sourceid in the parent package. the content of the DAT file is enough, while the IPA package is compressed in the same zip format. The basic idea is to decompress the parent package through zip and then change the sourceid. the content of Dat can be compressed into the corresponding channel package by zip.
IPA package directory:
Note: For specific examples, see the appendix.

Some Problems

When some shell commands do not work on Mac terminals, make sure that your shell scripts are written in the Mac environment instead of copied from other environments such as XP. Because the Mac and XP encoding are different, there may be problems.

Summary:

This method uses the parent package to output packages from other channels: the following benefits are obtained:

I. Reduced the RD workload and QA workload.

Ii. control risks when testing the release program.

Iii. Improved packaging and publishing efficiency. (Dozens of packages only take a few minutes ).

Iv. Improved automation.

V. Generate other packages from the parent package directly in Linux without relying on Mac or xcode.

The appendix uses the xcode environment to generate the shell script code for all packages at a time: C/C ++ code copies the content to the clipboard.
  1. #! /Bin/sh
  2. Xcodebuild clean-configuration distribution // Clean Project
  3. Distdir = "/users/xxxx/Dist"
  4. Releasedir = "build/distribution-iphoneos"
  5. Version = "1_0_0"
  6. Rm-RDF "$ distdir"
  7. Mkdir "$ distdir"
  8. For line in $ (cat data. dat) // read the data. dat file of all channel numbers
  9. Do
  10. Ipafilename = 'echo $ Line | cut-F1-d': ''// channel name
  11. Sourceid = 'echo $ Line | cut-F2-d': ''// channel number
  12. Echo "ipafilename = $ ipaname"
  13. Echo "sourceid = $ sourceid"
  14. Targetname = "youtargename" // project name (project name displayed in the list on the left of xcode)
  15. Echo "sourceid = $ sourceid"
  16. Echo "ipafilename = $ ipafilename"
  17. Echo "$ sourceid"> sourceid. dat
  18. Echo "sourceid. DAT :"
  19. Cat sourceid. dat
  20. Rm-RDF "$ releasedir"
  21. Ipapath = "$ {distdir}/$ {targetname }_$ {version }_from _ $ {sourceid}. IPA"
  22. Echo "*** start to build the app file ***"
  23. Xcodebuild-target "$ targetname"-configuration distribution-SDK iphoneos build
  24. Appfile = "$ {releasedir}/$ {targetname}. app"
  25. If [$ sourceid = "appstore"]
  26. Then
  27. CD $ releasedir
  28. Zip-R "registry.targetname=_registry.ipafilename=_registry.version=.zip" "$ {targetname}. app"
  29. Mv "${targetname1__${ipafilename=.zip" $ distdir 2>/dev/null
  30. CD ../..
  31. Else
  32. Echo "***** getting started with IPA channel package ****"
  33. /Usr/bin/xcrun-SDK iphoneos packageapplication-V "$ appfile"-o "$ ipapath" -- sign "iPhone distribution: xxxxxx"
  34. Fi
  35. Done

 

Note: The above data. the DAT file is the file that stores the channel number list in the format of 3G: 1001b (channel name: Channel Number) sourceid. dat is the file that stores the channel number in the project file (the content has only one channel number ). Of course, the above script only illustrates how to use xcodebuild and xcrun to package and automatically package the logic. The shell script can be used freely...

Generate shell script instances for other channel packages from the IPA parent package: copy the content to the clipboard

  1. #! /Bin/sh
  2. Sourceipaname = "parent package name. IPA"
  3. Appname = "app file name. app" // after pressurization, pauload directory item. app file name needs to be modified according to your project
  4. Distdir = "/users/LXXX/QA" // package file storage directory
  5. Version = "1.0.0"
  6. Rm-RDF "$ distdir"
  7. Mkdir "$ distdir" Unzip $ sourceipaname // extract the parent package file
  8. For line in $ (cat data. dat) // read the channel number file and perform a loop
  9. Do
  10. Ipafilename = 'echo $ Line | cut-F1-d ':''
  11. Sourceid = 'echo $ Line | cut-F2-d ':''
  12. Echo "ipafilename = $ ipaname"
  13. Echo "sourceid = $ sourceid"
  14. Targetname = "IPA package name"
  15. Echo "sourceid = $ sourceid"
  16. Echo "ipafilename = $ ipafilename"
  17. CD Payload
  18. CD $ appname
  19. Echo "replace sourceid. dat before :"
  20. Cat sourceid. dat
  21. Echo "$ sourceid"> sourceid. dat
  22. Echo "replace sourceid. dat after :"
  23. Cat sourceid. dat
  24. If [$ sourceid = "appstroe"]
  25. Then
  26. CD ..
  27. Zip-R "using your targetname1__using your version1__from_using your sourceid=.zip" $ appname // appstore binary file
  28. Mv "commandid targetname1__1_version1__from_1_sourceid=.zip" $ distdir
  29. CD ..
  30. Else
  31. CD ../..
  32. Zip-R "$ {targetname }_$ {version }_from _ $ {sourceid}. IPA" payload // pack the package in other channels
  33. Mv "$ {targetname }_$ {version }_from _ $ {sourceid}. IPA" $ distdir
  34. Fi
  35. Done Rm-RDF Payload

 

Note: The above data. dat is used to store all channel numbers. sourceipaname is the parent package verified by QA, the appname is the file name of the app under the payload directory after the IPA package is pressurized. All the above files must be in the same directory as the script file and executed in the Mac environment.

Original: http://stblog.baidu-tech.com /? P = 1295


Post analysis:

In xcode4.3, traditional IOS packaging:

Use xcode to package

Channel IPA package
Configure the Distribution Certificate, and click "build"> "ARCHIVE" to compile the program and automatically bring up the archive configuration page. You can also select archives in the Left bar of "organizer", select the compiled package from the list on the right, and click "Distribute" on the top right of the package, select the save for enterprise or ad-hoc deployment option, click Next, select the code sign certificate, and then click Next to save it to the disk. A. IPA file is generated as a channel package. If you want to generate a plist file for the network, select Save
For enterprise distribution.

Note: The above running device must select "deveice"

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.