iOS uses Jenkins for continuous integration

Source: Internet
Author: User
Tags ftp file

This paper mainly describes the continuous integration of ios-jenkins in the process of development to improve work efficiency.

Background

Usually we develop the iOS project and need to package it for testing. The process needs to be repeated: Modifying the configuration item--Compiling---Connecting the device--running the packaged--debug into the device--and handing it over to the waiting tester. The existing proven continuous integration Jenkins solution, which also provides support for the Xcode plugin, can be encapsulated as a one-click solution.

I realized that Jenkins performed iOS Job,build project, signed the IPA package, uploaded it to the FTP server, and put it under Tomcat to provide an HTTP download and install app.

Process

1. Download and install Jenkins

website address:https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins#InstallingJenkins-Unix%2FLinuxInstallation

After the download, is a war package (background service), is required to have JDK.

Then directly click Jenkins.war to run, access to http://localhost:8080/can

You can also run Java-jar Jenkins.war--httpport=8888from the command line; http://localhost:8888/

can also be placed under Tomcat.

After running, a. Jenkins directory is created under user.

2. Add Xcode Plugin

In the system management of Jenkins, find the management plug-in, the optional plug-in search for Xcode, tick install, install plugins/upgrades waiting for-jenkins to upgrade to the latest version, the Xcode plugin is better installed (if the failure please download the latest jenkjins, or try more than a few times).

If you restart Jenkins this way, you'll see the support options for Xcode in the job's build drop-down selection.

3. New Job

Create a new free job.


4. Source Control

If you use SVN, choose Subversion, point to the address directly, if you do not use SVN, select None, you need to run the next job, so that the working directory of Jenkins creates a result failed job, the directory is. jenkins/jobs/ Your job name/. At this time, the directory under the job and Builds,workspace directory files, we need to workspace into our code project (this is the official solution).

See the directory structure.

So there's code in the workspace.

5. Building the Xcode project

In the Add Build step dropdown, select Xcode.

For example, simple configuration parameters, the execution of the project's target,configuration is debug (see the situation choose release), there is also a pack application and build. IPA option, this I did not choose.

There is also a code signing and key chain options, can not be filled out, will automatically find the default (the project is configured bar, you can see in the runtime console in the execution of the log, the output will do what each step).

Here's a more advanced parameter configuration for Xcode,

Scheme configuration, and the SDK that requires build to run, choose Iphoneos (This is to be run on the real machine) and the built output directory.

In this case, the emulator of the matter, here can not be configured to Iphonesimulator, because it is useless, the simulator can not be run up, first Apple Unix command to start the simulator, But did not provide the API to the command line to install the IPA program in the Emulator and run (Xcodebuild command without this support), the Internet found a solution, found that it was a long time ago, 4 years ago, there is a GitHub plug-in, but the plug-in project needs to rely on Iphonesimulatorremoteclient.framework This library, and now the Mac can not search this library, so can not run, so command line to start the emulator, and install the way to run the IPA, only the real way to.

Run the job, you should be able to present the current directory file, the IPA will not come out.

Now here, it means that the job of Jenkins's iOS is basically OK.

6. Then we will implement the Packaging IPA file

The above Xcode configuration Pack application and build IPA I did not choose, that has not been clarified, its output directory context into Jenkins, and the actual generated IPA in the installation directory of Xcode is a very hidden directory, this is not clear.

And I'm doing it through the shell, the command-line way.

Select Add build step, click Shell, and then a command line input box appears, see figure.

According to the command on the diagram, select the SDK packaging app to specify the output directory file, so that the build after the completion of the directory structure of the IPA file, this is what we need to install the program, signed can be installed by the real machine. Specify commands to add signatures and descriptions see Xrun's command description.

OK, we've done a big step.

7. Now let's set up the FTP upload feature.

The MAC itself supports the FTP service and discovers a handy software to modify the system, lion tweaks,

Find the FTP on the right, and turn it on.

We need to set up the system configuration of Jenkins-system management link on the left side of the root path, click to open and then select the system settings, down to find the FTP configuration items, see figure:

I set up my own computer, so localhost is up. Set the root path of the FTP root repository path, which is populated with the user name password for this computer.

Set up your own job's FTP service,

See figure, set the file to be uploaded and its corresponding directory, now the IPA program file upload, we need to the build directory after the creation of the IPA file upload to the FTP server directory, we for the subsequent mobile phone download through the Tomcat service , so upload to the Tomcat directory.

Upload success will have this directory structure under Tomcat, see figure:

This enables us to upload files to the FTP server.

8.Tomcat Service

Then we need to set up the Tomcat service to make it easy for mobile phones to download and install our app from the Web.

Download Tomcat, go to the Tomcat Bin directory, execute the command,

SH startup.sh

Start Tomcat.

Create a simple Web project, this simply look at the web itself implementation, and then put under Tomcat WebApps, modify the Tomcat access Port 8088, and the jenkins8080 conflict, so when we visit Tomcat,

will be able to access our project, http://localhost:8088/hello_jenkins2/index.jsp.

9. Download Support Files

Now description of our Jenkins job ftp other file upload is what, ios_down.html is to provide a webpage that can click on a link to download the installer to the phone. The relative hello_jenkins.plist file is a file that supports the IPA file download to your phone.

Ios_down's link protocol points to this plist,

<a href= "itms-services://?action=download-manifest&url=http://192.168.200.124:8088/hello_jenkins2/ Publish/hello_jenkins.plist ">

This hello_jenkins.plist inside and points to IPA

The contents are as follows

<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE plist Public "-//apple//dtd plist 1.0//en" "Http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
<plist version= "1.0" >
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>http://192.168.200.124:8088/hello_jenkins2/static/build/debug-iphoneos/hellojenkins.ipa</ String>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>com.hai.HelloJenkins</string>
<key>bundle-version</key>
<string>1.0</string>
<key>kind</key>
<string>software</string>
<key>subtitle</key>
<string>HelloJenkins</string>
<key>title</key>
<string>HelloJenkins</string>
</dict>
</dict>
</array>
</dict>
</plist>

In this way, when browsing the Web ios_down.html, click on the install tag, then point to the Hello_jenkins.plist file, and the resolution to the IPA file, the phone also prompts to download the installation hello_jenkins, download and install.

10. Complete

Mobile Access

Http://192.168.200.124:8088/hello_jenkins2/publish/ios_down.html

I have installed to the mobile phone, do not send a map.


11. Finally take note of some issues

Note the path problem, if the job FTP file upload path, HTML files and the path of the plist file is a bit wrong, will cause the inability to access and so on can not download the problem.

Also note that the base SDK of the installer is compatible with the real machine, otherwise it will not be installed.

Note that the FTP upload directory is based on the user directory of our system settings.

There is the upload file directory is not on, Jenkins is not error, and output log prompt not found file, so look more job log.

There is sometimes plist file is clearly right, but is the display can not be accessed, please try to copy an plist file elsewhere, in the modification of the content, I have appeared, copy a copy is good.



Ps:

Online this is not much, I took the time to study the next, dedication to everyone, there are some doubts not clear, follow-up and supplemented.





iOS uses Jenkins for continuous integration

Related Article

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.