Advertisement

Continuous Integration: Series Introduction

by

In this tutorial series we will explore a rarely discussed (but highly valuable) process of
developing software that is disappointingly absent in the iOS and mobile world: Continuous Integration.

In a nutshell, Continuous Integration (CI) allows you to speed up the development and release process by constantly checking the code repository for build issues as well as automating a variety of procedures that you would otherwise have to perform yourself.

After reading this tutorial you will be able to set up from scratch an automated server that will provide all of the above benefits (plus a few more). Specifically, we will cover:

  1. The theory behind continuous integration.
  2. Installing the Tomcat Apache Webserver. This will be used to run the CI software.
  3. Installing Hudson. This is the CI software that will monitor the repository and start the
    build.
  4. Writing the bash build script.We will go through the basics of Bash and how to compile our Xcode project from the command line.
  5. Extending the build script in various ways, including automated deployment.

Required Knowledge

Although we will go into detail about all aspects of how to set up your CI, it is assumed you have no prior knowledge of server administration, bash scripting, or CI procedures. Having said that, it is expected that you have a general grasp on Xcode and archiving builds, and also that you understand (and have access to) a source control server.

If you are not already at the point where you are using a version control system such as Git or SVN for managing your code, this tutorial will be a little out of your comfort zone. To learn about source control and how it can benefit you, I highly recommend signing up to GitHub. They offer free public repositories and have a great tutorial for new users on how to set up and use Git as a VCS.


Also available in this series:

  1. Continuous Integration: Series Introduction
  2. Continuous Integration: Tomcat Setup
  3. Continuous Integration: Hudson Setup
  4. Continuous Integration: Scripting Xcode Builds
  5. Continuous Integration: Script Enhancements

What Is Continuous Integration?

As anyone that has worked in a team of developers can attest, managing code repositories and code conflicts can be a huge pain. Developers can spend several hours after a merge managing and cleaning up conflicts.

As well as working with conflicts, manually building apps for testing or enterprise distribution can take a significant amount of time. Someone has to be responsible for keeping their repository up to date, managing the developer certificates and provisioning profiles, archiving the code, and uploading the IPA file to a server for distribution.

Because of the complexities involved in these procedures, developers are sometimes loathe to commit and build their code and will manage to make a build of the full project only once or twice a week.

CI allows the builds to be automatically started after every commit to the repository. This allows errors in the code and conflicts to be easily identified and resolved quickly and effectively.Although this is useful, by far the most useful feature that we can get from setting up a CI server is automating and distributing our builds. Imagine if all you had to do was type svn commit -m "Fixed the customer ID bug" and 30 seconds later the build was sitting on a website waiting to be downloaded by a tester. Setting up a CI can make that happen!


How It Works

For CI to work effectively, developers need to commit early and commit often (at least once a day). The CI server continually polls the repository to check if there has been an update. If it detects a change, it will begin building the project and performing any associated tasks.


If the build is successful, the team is notified of the successful build. If the build is not successful, the team is notified of:

  • Who on the team broke the build
  • What changes caused the build to break

In the event of a broken build, the team can quickly asses how the build broke and go about resolving the problem, and the problems that need fixing are small and easy to manage because we are committing every day instead of every week.


The Main Advantages Of Continuous Integration

  • Problems with the build are identified early.
  • Identified problems are usually small issues that are easy to resolve.
  • Automated building, signing and distribution of the app saves time.
  • Constant access to the 'latest' build for testers.
  • Unit tests can be run on every build, allowing developers to detect functional issues as well as compilation errors.

Unit testing is a world onto itself and unfortunately will not be covered in this tutorial. I encourage you to read up about using unit tests as not only part of your CI but a part of your development process.


The Main Disadvantages Of Continuous Integration

CI is certainly not for everyone. It can take a significant amount of time to set up a server for your needs. The CI server software is best installed and set up on a separate machine to that being used for development and the hardware requirements. That means extra costs for hardware.


Next Time

In the next article we’re going to get our hands dirty setting up the Tomcat web server. We’ll cover system requirements, how to install it, and starting/stopping the server. Catch you next time!

Advertisement
Related Posts
  • Code
    Mobile Development
    WWDC 2014 AftermathPreview image@2x
    WWDC is like Christmas for Cocoa developers, and this is certainly true for this year's edition due the scarcity of leaks and rumors leading up to the conference. Even though we're all curious to hear what Apple has in store for everyone loving Apple, the keynote is much more fun when you have no clue what's about to be announced, like this year. If you've seen Tim Cook's keynote, then I'm sure you agree that Apple surpassed everyone's expectations. Let's take a few minutes to summarize what Apple has announced, what it means for developers, and what you can expect later this year.Read More…
  • Code
    Web Development
    Easily Deploy Redis Backed Web Apps With DockerDocker wide retina preview
    Learn how to setup and deploy a Redis powered Python web app using Docker.Read More…
  • Code
    Web Development
    Testing Your Ruby Code With Guard, RSpec & Pry: Part 2Ruby wideretina preview
    Continue learning test-driven development in Ruby with Guard, RSpec and Pry.Read More…
  • Code
    Mobile Development
    iOS: Tools of the Trade741pm preview image@2x
    There are numerous tools and services that have become indispensable in the workflow of many Cocoa developers. In this article, I will highlight some of the tools that I use as well as some alternatives.Read More…
  • Code
    Tools & Tips
    Travis-CI: What, Why, HowTravis retina logo
    Travis CI makes working in a team for a software project easier with automated builds. These builds are triggered automatically when each developer checks in their code to the repository. In this article, we will go through how we can integrate Travis CI easily with our project, which is hosted on Github. With automation, notification and testing in place, we can focus on our coding and creating, while Travis CI does the hard work of continuous integration!Read More…
  • Code
    General
    Team Collaboration With GitHubGithub team preview
    GitHub has become the corner stone for all things open source software. Developers love it, collaborate on it and are constantly building awesome projects through it. Apart from hosting our code, GitHub's main attraction is using it as a collaborative tool. In this tutorial, let's explore some of the most useful GitHub features, especially for working in teams, making it all the more efficient, productive and, most importantly, fun!Read More…