ci & cd- mobile application

22
Continuos Integration For Mobile Application Using Ship.iO CI Tool 1

Upload: kishan-ravindra-httpaboutmeravindrakishan

Post on 29-Jan-2018

116 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CI & CD- mobile application

Continuos Integration For Mobile Application Using

Ship.iO CI Tool

�1

Page 2: CI & CD- mobile application

PREFACE:

As a mobile application developer,I always wondered about the process of continuous Integration and delivery for mobile applications. Because of its advantages In faster code deployment and detecting the defects in the application earlier.

So, I started doing online R&D for the continuous Integration tool for mobile applications both for Android and iOS.

As a result, I found the tool called Ship.io, which I thought will meet the process requirement for CI and CD for mobile applications.

In this document, the CI and CD process will be explained for iOS project in 3 steps.

Step-1: The project workspace structure - iOS .

Step-2 : Ship.Io 2.1: The process of setting up the ship.io tool 2.2: Giving access of your project repo to Ship.io.

Step-3: Continuous Deployment of iOS app for beta test through Ship.io

�2

Page 3: CI & CD- mobile application

Before we prepare our project for CI process. Let us know…

1. What is continuous Integration? “Continuous Integration is a development practice, where developers needs to Integrate source code Into repository several times a day. Each code push into repo, Is then verified by automated build, allowing developers to detect problem early”.

“Continuous Integration doesn’t get rid of bugs, but it does make them dramatically easier to find and remove.” - Martin Fowler, Chief Scientist, ThoughtWorks.

2. How continuous Integration process helps In mobile application development? The process of continuous Integration is very cost effective. If we don't follow the CI process, there will long gap between the each Integrations, which make it exponentially difficult to find and fix problems In your applications as early as possible .

For example ,the release of iOS application much different from Android application or web application.On average Apple review process takes 5 days compare to 1 day review process of Google Android. If end user finds any of the Issue In the released application. It takes much time to fix that Issue and release it again to end users.

The cost of a mobile application error is greater than that of a web application error. Because it takes much longer time to fix. Making it even more complex, with the number of different test devices.

So, by applying CI for mobile applications. Developer can constantly Check-In the developed code to repo and verified automated build will alert the team members , In case of build fails. Then the team fix the issue at the earliest, before going out for production.

�3

Page 4: CI & CD- mobile application

STEP-1: The project workspace structure - iOS

To prepare any of the iOS project for CI or CD. You need to an workspace of the existing project.

(A workspace is a concept of grouping together a set of related project, configuration files and library .So you can work on them.A workspace provides implicit and explicit relationships among the included projects and their targets.)

Open a existing iOS project (.Xcodeproj) In Xcode. Click on the File in the menu bar >> New >> Workspace

Once you click on the workspace, It will ask you to save the workspace project. So, save the workspace In your respected project folder.

�4

Page 5: CI & CD- mobile application

You should be able to see, empty project and Project Structure as below .

Project Structure.

�5

Page 6: CI & CD- mobile application

Drag the project file (.Xcodeproj) into the Xcode.

Finally, go to the Product In the menu bar and select >> Scheme >> Manage Scheme.

�6

Page 7: CI & CD- mobile application

Once you click on the manage scheme, a dialog box will appear. Make sure the projectName.xcodeproj have a shared checkbox clicked, otherwise click the shared checkbox to make your project shared one to work with workspace project.

Now, our project meets all the setup requirement needed by Ship.io tool .Once you done with your project setup and next Important thing Is to check-in the code In Github repo or Bit-Bucket. Since Ship.io need access to your code repo to build the automated build.

Assuming everyone know how to check-In the code to Github repo. I’m moving to step-2.

�7

Page 8: CI & CD- mobile application

Step-2 :Ship.io 2.1. The process of setting up the ship.io tool.

Visit https://ship.io and create a free account by clicking on Signup.

Enter your E-mail Address and Password. That’s it your Ship.io account is ready for CI.

�8

Page 9: CI & CD- mobile application

Once you done with the creating of your account.You should be able to see the below screen.

Click on “Select you app via Github,SSH or HTTPS”. Once you clicked on that button, you will be redirected to Github access page.This Is the page, where we going to give access of our Github or Bit-Bucket repo to Ship.io tool.

�9

Page 10: CI & CD- mobile application

Just click on “GITHUB” and tap connect button on the bottom right corner. Once you click on the connect, the Ship.io tool will ask you for the authorisation access to your Github repo. Provide the access by tapping on access granted.

Once the access is granted, the ship.io will start fetching all the repo’s present In your Github account and list it out.

These are basic necessary setup In ship.io tool to Implement CI and CD for any project.

�10

Page 11: CI & CD- mobile application

2.2. Giving access of your project repo to Ship.io.

Once all the projects listed out, you need to select the project from the list, which already have workspace setup for ship.io. Once your select your project from the list, click on the scan.

Clicking on scan allows the Ship.io to scan through the project repo. Which In turn starts cloning the project and analysis all the project dependencies,library,framework and especially workspace availability.

Once analysis of the repo Is completed. You will be redirected to “Create Job” page. Must sure schedule is selected to commit hook, the commit hook will take care of any newly made commit to your repo and instantaneously tells the ship.io to scan the repo once again.

As of now, you might seen a warning showing “You haven’t added any steps to this job yet.” under build steps. Ship.io asking you to specify, what type of automated build you want to setup, either application or tests.

�11

Page 12: CI & CD- mobile application

Click on the “+ Add build step” and select “Build An iOS Application”. Here we are telling Ship.io to build automated build for application.

Once clicked on “Build An iOS Application”, a new dialog box will appear. Which already have a populated workspace and Scheme name. Now click on “Package App with ship.io Build Number” and click OK, which will automatically update a build number when new code scanned by Github repo.

�12

Page 13: CI & CD- mobile application

Now the “Create Job” page should look something like below and finally click on “+Create Job”.

Clicking on “+Create Job”, Ship.io tool start constructing automated build.

If the build Is succeed. The Status will be shown as “Succeeded” or else “failing”

�13

Page 14: CI & CD- mobile application

You can see complete automated build process, by clicking on status tile.

Once you tap on the tile, It will show the detail process of complication and automated build.

Hurry!.We successfully built our first build. You can intimate your team member about successful build, by adding team mate email address. To add team mate email address,click on menu button, right next to your account name and Click on Team option from the drop down.

Clicking on Team, will redirect you to team page. Where you need to add team name, specify Job name(project name) and enter the team mate mail address to send an Invite.

�14

Page 15: CI & CD- mobile application

After adding team member.Your team page should look like this.

Thats It. Your team mates will receive a notification, Whenever new build get succeed. An mail will notify your team mate about the successful build.

�15

Page 16: CI & CD- mobile application

Step-3: Continuous Deployment of iOS app for beta test through Ship.io

To deploy the iOS application for beta testing through ship.io. Go to menu and select “Code Signing” from drop down.

Once you clicked on “Code Signing”. It will open a code signing page, where you need to add the developer and distribution certificate(.p12 file) to ship.io dashboard. (Download the developer or distribution certificate (.cer)from Apple member account. Double click on the certificate to open It on keychain access, then right click on the certificate and select “Export”. It will generate the .p12 file).

�16

Page 17: CI & CD- mobile application

Add both developer.p12 and distribution.p12 file by clicking on “+ Add Certificate” and finally add the application distribution provisional profile certificate by clicking on “Provisional profile” Tab and add the certificate.

�17

Page 18: CI & CD- mobile application

Now Ship.io tool is ready for your application deployment. Now we need to go back to our Xcode project. In order to generate the .ipa file, once you generate the .ipa file, add it to the project structure and update the Github repo.

To generate an .ipa for your application. Open a distribution certificate by double clicking on it. Select a project target >> Build Setting >> Code Signing.

Once you add the distribution certificate, clean the code(command+shift+K). Now archive the application to create .ipa, select the product from menu bar >> Archive.(Make sure that, active scheme is pointing to iOS device).

�18

Page 19: CI & CD- mobile application

Once archiving of the application completed successfully, save the .ipa file In the project folder and commit/Check-In the code to Github repo.

Your project structure should like this. Now go to Jobs page In Ship.io tool and click on edit below the project name.

Clicking on edit will open Create job page. Select the edit button from Build step >> Build An iOS Application >> Edit. It will open a dialog box, choose code signing and give distribution access by clicking check box “Sign this build”,selecting developer certificate and provisional profile and finally save the create job.

�19

Click here

Page 20: CI & CD- mobile application

Once you done with giving certificate access. Click on “Start build” In Jobs page, which will start analysing new code and .ipa file, which has been newly Checked-In to repo. Then Ship.io starts creating a package file of ipa for distribution.

�20

Page 21: CI & CD- mobile application

You can see successful packaging of .ipa file by tapping on build tile. Once application and .ipa is successfully complied and packaging Is done. You can send .ipa file for beta tester. To do so, click on send OTA notification.

Once the beta tester receive an application build file, he/she can Install It Into there device.

Build Notification:

�21

Page 22: CI & CD- mobile application

This Is the basic way to Integrate your mobile application for Continuous Integration and Continuous deployment.

Resources:

1. https://support.ship.io/ios 2. https://www.youtube.com/watch?v=joc1QbYhqhw 3. [PDF] Why CI Should Be Part of Your Mobile Dev Process - from Sauce

Labs 4. Logo - Ship.io copyright.

-Kishan Ravindra iOS Developer Qwinix Technologies Pvt Ltd

�22