continuous integration for ios with xcode server

34
CONTINUOUS INTEGRATION for iOS

Upload: kiel-oleson

Post on 15-May-2015

2.921 views

Category:

Technology


0 download

DESCRIPTION

With Apple’s App Store review process, making your submission bug-free and high-quality is of utmost importance. Continuous Integration is a testing practice utilized to ensure a highly-tested build is always available for shipping. Jenkins is a popular continuous integration suite, but it was not designed for iOS development and has several limitations. Apple released their continuous integration server, Xcode Server, with Xcode 5 last summer. In the talk, we examine the prerequisites to setting up continuous integration, the details of creating bots on Xcode Server, and the features that are available on Xcode Server along with their uses. Finally, we present a list of caveats to be aware of when planning a continuous integration implementation. Kiel Oleson is an iOS Mobile Software Engineer at Eventbrite in San Francisco. Since joining Eventbrite in 2010 as their first dedicated iOS engineer, he has led from-scratch development of Eventbrite’s eponymous application for event attendees and Eventbrite At The Door, a ticket point-of-sale system. Prior to writing software for iOS, he wrote WebKit-based software for Mac OS X with Cocoa and Qt. Kiel is an advocate of test-driven development and continuous integration in the iOS community, from its roots in UIAutomation, OCUnit and shell scripts to today’s KIF, XCTest, and Xcode Server. Kiel moved to San Francisco from Missouri and is a graduate of the Raikes School at the University of Nebraska. When he isn’t improving his software’s reliability and user experience, he is in his car trying to improve his lap times at the racetrack.

TRANSCRIPT

Page 1: Continuous Integration for iOS with Xcode Server

CONTINUOUS INTEGRATION for iOS

Page 2: Continuous Integration for iOS with Xcode Server

KIEL OLESON@KielO

Page 3: Continuous Integration for iOS with Xcode Server

CONTINUOUS INTEGRATION

• Keep the build alive

• Run all the tests, all the time

• TDD’s best friend

• The intersection of development and QA

Page 4: Continuous Integration for iOS with Xcode Server

CONTINUOUS INTEGRATIONSOURCE CONTROL

TESTS SERVER

CI

Page 5: Continuous Integration for iOS with Xcode Server

JENKINS

• Must run on OS X for simulator support

• Fragile build scripts

• Even more fragile run scripts

• Reporting is e-mail based

Page 6: Continuous Integration for iOS with Xcode Server

is here.AN ALTERNATIVE

Page 7: Continuous Integration for iOS with Xcode Server

XCODE 5Xcode Server and Bots

Page 8: Continuous Integration for iOS with Xcode Server

PREREQUISITES

• Source Control

• Dependency management

• CocoaPods

• git Submodules

• Schemes

• TESTS.

• Things to make tests possible

• categories

• mock objects

• mock server

Page 9: Continuous Integration for iOS with Xcode Server

SOURCE CONTROL

• You are using Source Control, right?

Page 10: Continuous Integration for iOS with Xcode Server

DEPENDENCY MANAGEMENT

Page 11: Continuous Integration for iOS with Xcode Server

DEPENDENCY MANAGEMENT

Page 12: Continuous Integration for iOS with Xcode Server

XCODE SOURCE CONTROL

• Submodules

• Goofy branch behavior

• xccheckoutdata

• Important to make it happy since it’s the one telling CI what to do

Page 13: Continuous Integration for iOS with Xcode Server

SCHEMES

• Shared

• You are committing /xcshareddata/, right?

Page 14: Continuous Integration for iOS with Xcode Server

TESTS

• You are writing tests, right?

• OCUnit

• XCTest

• Something else?

• Too bad!

Page 15: Continuous Integration for iOS with Xcode Server

MAKING TESTS POSSIBLE

• KIF

• Test your UI like a user!

• Mock Objects

• Test your objects like a caller!

!

• Mock Server

• Test your API responses without a server!

Page 16: Continuous Integration for iOS with Xcode Server

ASIDE: KIF

• You are making your app accessible, right?

• Use accessibility labels to UI test your app

• KIF-Next aka KIF 3.0

• XCTest-based

• https://github.com/kif-framework/KIF

Page 17: Continuous Integration for iOS with Xcode Server

ASIDE: TEST BUNDLES

• OCUnit and XCTest run inside main target

• Need to be crafty to make certain things work

• Location Services without human interaction

• Clearing Core Data, etc.

Page 18: Continuous Integration for iOS with Xcode Server

XCODE 5and Bots

Page 19: Continuous Integration for iOS with Xcode Server

TEST NAVIGATOR

Page 20: Continuous Integration for iOS with Xcode Server

TEST NAVIGATOR

• You are running your tests, right?

• Run by...

• Suite

• Class

• Test

Page 21: Continuous Integration for iOS with Xcode Server

TEST NAVIGATOR

• Deep integration

• Click a test name to see the code.

• Test failure breakpoints

• See Bot results in Xcode

Page 22: Continuous Integration for iOS with Xcode Server

BOTS

• From Jenkins world? Think of them as very focused jobs.

• One bot configuration

• One branch

• One schedule (daily, hourly, on commit)

• One target

Page 23: Continuous Integration for iOS with Xcode Server

BOTS - EXAMPLES

• On commit, make sure project builds with 0 errors, 0 warnings, 0 SA results

• On commit, make sure project builds with 0 test failures.

• Nightly, post a new build and keep it around for posterity

Page 24: Continuous Integration for iOS with Xcode Server

INTEGRATION

Page 25: Continuous Integration for iOS with Xcode Server

WEB INTERFACE

Page 26: Continuous Integration for iOS with Xcode Server

SCOREBOARD

Page 27: Continuous Integration for iOS with Xcode Server

SIMULATOR TESTING

• Fast, basic coverage

• Cheap

• Not a substitute for on-device testing

Page 28: Continuous Integration for iOS with Xcode Server

ON-DEVICE TESTING

• Real-world performance and functionality

• Hook up devices to run tests on more targets

• Form factors

• iOS versions

• 32-bit and 64-bit

Page 29: Continuous Integration for iOS with Xcode Server

CAVEATS

• Submodules must be at HEAD of branch

• Simulator keeps state between build runs

• Make your tests and targets idempotent

• git commit polling sometimes breaks

• HTTP guest login is broken

• No CocoaPods for you

Page 30: Continuous Integration for iOS with Xcode Server

XCODE SERVER SECRET LAIR

Page 31: Continuous Integration for iOS with Xcode Server

XCODE SERVER SECRET LAIR

• /Library/Server/Xcode/

• /private/var/_xcstest

Page 32: Continuous Integration for iOS with Xcode Server

DON’T FIGHT THE FUTURE“These are all new technologies that are a core of iOS 7 and had multiple sessions dedicated to them at Apple’s major developer event. You can

be damn sure that the company is proud of them, and looking for developers to highlight who have integrated them into their apps.”

!

- Justin Williams (@justin)

Page 33: Continuous Integration for iOS with Xcode Server

ADDITIONAL RESOURCES

• CI Example Project

• With Submodules

• Without Submodules

• http://github.com/koleson/

Page 34: Continuous Integration for iOS with Xcode Server

🎉