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:
- Jenkins setup configuration, task construction
- iOS development environment configuration
- iOS packaging (certificate configuration)
- 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:
- Development certificate
- < 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>
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.
span>
running on real machine
There are two ways to run the real machine: span>
- One is that no certificate description file is required but an appleID account password is required
- 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"> 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
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
xcodebuild -usage View xcodebuild usage - xcodebuild- showsdks View the installed sdk
- 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
- xcodebuild Export the archive file as an ipa file -exportArchive -archivePath
-exportPath span>– exportOptionsPlist #This plist file can be obtained by hitting the ipa package once, and then modify it as required
< li data-slate-object="block" data-key="y88mk1rvygdj">xcodebuild builds and generates archive files archive-archivePath -scheme
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
- 一种方式是先将项目构建成.app文件,通过xcodebuild build, 然后使用xcun 将app文件导出生成ipa,但是目前新版本的不支持这种方式了,一般用2
- 另外一种方式就是先构建生成.xcarchive文件, 然后导出生成.ipa文件
注意一点的是,plist文件我们可以通过用Xcode打包一次获得,然后根据需要修改,也可以参数化,内容如下:
http://www.apple.com/DTDs/PropertyList-1.0.dtd“>
xcodebuild打包脚本
知道了如何用命令行进行打包后,我们可以自己写个简单的脚本来进行打包,然后集成到Jenkins的话直接执行脚本,不使用Jenkins提供的Xcode插件,更加方便。