iOS Jenkins Automation Packaging Build

Foreword

In the process of testing app projects, it is usually required The development and testing package is given to the test, but the packaging process for both iOS and Android is quite long. Frequent regression testing requires frequent packaging, which has a considerable impact on the development students. Therefore, in this case, development usually builds a simple automated packaging platform (Jenkins), automated build packaging or upload to Dandelion, firm and other distribution platforms. As a test, you also need to understand relevant knowledge, because these tasks may also be tested to do or to promote development to do related work to optimize and improve the efficiency of development and testing.

Technical points involved:

  1. Jenkins setup configuration, task construction
  2. iOS development environment configuration
  3. iOS packaging (certificate configuration)
  4. The use of iOS command line packaging xcodebuild

xcode packaging introduction

Preparations

If you don’t package it, you don’t need a certificate and description file to run the app directly on the test machine. As long as there is an Apple ID, it can automatically generate a description file, and then let the app run on the test machine.

If you need to package and distribute, it must have Certificate and description file.

There are two types of certificates, one is the development certificate, and the other is the online certificate. Of course, you only need to get the development certificate for testing. In most cases, you don’t need to go online. Tested (involving some developer accounts and other things).

If we need local packaging, then we need to follow the development Two things are required:

  1. Development certificate
  2. < span data-slate-object="text" data-key="ubrnaltswyqwj">Description file

After obtaining the development certificate, double-click to open it, and you can see the installed certificate in the keychain.

The description file needs to be saved separately, some configurations may be used So, it needs to be imported in the Xcode configuration.

code permissions, get code permissions with development, git clone to the local.

Xcode use< /span>

Xcode is an iOS development IDE. When using it, you need to use the version synchronized with the development. Some developments are Always use the latest version, and some may use the old version, which may cause problems.

check the local environment and code span>

Use Xcode to open the clone to the local code, if the version corresponds to everything, build There should be no problem.

command+b build the project and check for errors.

Or navigation bar: product→ Build

< span data-slate-leaf="true" data-offset-key="ezva5ac9l97h:0">share picture< span class="slatejs-editor-imgedit__holder slatejs-editor-imgedit__holder-bottomright" data-position="bottomRight">
< /span>

If there is nothing wrong , It will be OK if you can compile and build successfully.

simulator operation

If only the simulator is running, there is no need to configure the certificate description file, select the simulator type, Just run it directly.

share picture< span class="slatejs-editor-imgedit__holder slatejs-editor-imgedit__holder-topleft" data-position="topLeft">
span>

running on real machine

There are two ways to run the real machine: span>

  1. One ​​is that no certificate description file is required but an appleID account password is required
  2. One is to export the certificate description file to the .ipa package

In the first method, only the phone can be connected to the computer via USB, and then run the project and install the app on the phone

The second way is to export the ipa file transfer Install on your phone

The first way:

You can add an apple account through the navigation bar Xcode → Preferences → Accounts

< span data-slate-zero-width="z" data-slate-length="0">share picture< br> span>

configured in the project (target→ sanjieke), there is an Automatically manage signing, select the apple account after ticking, the configuration description file will be automatically generated

share picture
span>

If there is an error, read the error description, and then adjust the configuration, the general error is

The problem with buddle id

Issue of iOS version

After adjustment, there will be no problem.

The second way, real machine packaging

If it is an export package installation test, you also need to add the udid of the test machine in the developer center, and this will be used for development.

installed the certificate, got the description file, configure it in the project

is still the content of the red box in the above picture, do not click Automatically manage signing, click provisioning profile, select import profile, and import the description file. .

Then select Generic iOS Device in the simulator position

< span data-slate-string="true">Navigation bar Product→ Archive

Follow the prompts to select step by step, and finally the required ipa package will be generated under the path you choose.

xcodebuild command introduction

If you don’t want to manually package, you can also use command package

xcodebuild basic commands

  1. xcodebuild -usage View xcodebuild usage
  2. xcodebuild- showsdks View the installed sdk
  3. xcodebuild -list View project The target (target project), configuration (package environment debug, release) and schemes (project name), these three parameters are also needed for subsequent packaging
  4. < li data-slate-object="block" data-key="y88mk1rvygdj">xcodebuild builds and generates archive files archive-archivePath -project < span data-slate-object="text" data-key="puuew27kuti3"> -scheme #Get -configuration < span data-slate-leaf="true" data-offset-key="cs5sheepzmnq:0"> -sdk #sdkName can be obtained from the showsdks command Get span> li>

  5. xcodebuild Export the archive file as an ipa file -exportArchive -archivePath -exportPath – exportOptionsPlist #This plist file can be obtained by hitting the ipa package once, and then modify it as required span>

The actual application of the xcodebuild command

from the basic command point of view The most common ones are 4 and 5. In fact, there are two ways to export ipa files from the command line

  1. 一种方式是先将项目构建成.app文件,通过xcodebuild build, 然后使用xcun 将app文件导出生成ipa,但是目前新版本的不支持这种方式了,一般用2
  2. 另外一种方式就是先构建生成.xcarchive文件, 然后导出生成.ipa文件

 

注意一点的是,plist文件我们可以通过用Xcode打包一次获得,然后根据需要修改,也可以参数化,内容如下:

http://www.apple.com/DTDs/PropertyList-1.0.dtd“>          compileBitcode                    destination          export          method          development          provisioningProfiles                             com.sanjieke.app                   com.sanjieke.appDevelop                 signingCertificate         iPhone Developer         signingStyle         manual         stripSwiftSymbols                 teamID         V5LUS4979S         thinning         <none>

xcodebuild打包脚本

知道了如何用命令行进行打包后,我们可以自己写个简单的脚本来进行打包,然后集成到Jenkins的话直接执行脚本,不使用Jenkins提供的Xcode插件,更加方便。

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3867 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.