Managing iOS Continuous Integration at Enterprise Scale

LinkedIn Engineering Team
8 min readintermediate
--
View Original

Overview

The article discusses the challenges and solutions for managing Continuous Integration (CI) in iOS development at an enterprise scale, particularly focusing on issues faced with Xcode and the CI pipeline. It highlights specific problems encountered, such as simulator crashes and build failures, and provides actionable workarounds to enhance reliability and speed.

What You'll Learn

1

How to troubleshoot simulator crashes during CI builds

2

Why managing Xcode versions is crucial for CI stability

3

How to implement workarounds for race conditions in simulator launches

Prerequisites & Requirements

  • Familiarity with Xcode and iOS development practices
  • Access to a CI/CD pipeline and Mac hardware for testing(optional)

Key Questions Answered

What causes the app to crash when launched in the simulator?
The app crashes due to a race condition between installation and launch, particularly in Xcode 7.0.1 with iOS 8/9. The xcodebuild command may exit with 'BUILD INTERRUPTED' without clear error messages, leading to significant CI build failures.
How can missing simulator devices be resolved?
To resolve missing simulator devices, run 'launchctl list | grep CoreSimulator' to remove any CoreSimulator processes, delete everything under '~/Library/Developer/CoreSimulator/Devices', and then execute 'xcrun simctl list' to recreate devices. This ensures a clean slate for each CI job.
What should be done when the simulator times out during tests?
When the simulator times out, retrying the 'xcodebuild test' command often resolves the issue. It's important to avoid using 'simctl' to boot the simulator, as it may lead to a headless state; instead, use the 'open' command with the correct Xcode path.

Key Statistics & Figures

Percentage of CI builds failing due to simulator crashes
15 to 20 percent
This failure rate was observed during a particularly problematic week with Xcode 7.0.1.
Number of commits per day across all iOS projects
150 to 200
This high volume of commits amplifies the impact of CI build failures on the development team.

Technologies & Tools

Development Environment
Xcode
Used for building and testing iOS applications.
Build Tool
Gradle
Built plugins on top of native build tools to enhance CI processes.
Simulator Management
Coresimulator
Manages simulator devices and environments for testing iOS applications.

Key Actionable Insights

1
Implement a logging mechanism to capture simulator errors in real-time during CI builds.
This allows for quicker identification of issues and reduces time spent troubleshooting failed builds, enhancing developer productivity.
2
Regularly update and manage Xcode versions across CI nodes to prevent compatibility issues.
Keeping Xcode versions consistent helps maintain CI stability and reduces the likelihood of encountering unexpected build failures.
3
Adopt a sequence of commands to reset the simulator environment at the start of each CI job.
This ensures that the simulator is in a known state, preventing issues related to stale or corrupted simulator devices.

Common Pitfalls

1
Relying solely on 'simctl' to boot the simulator can lead to headless states, causing timeouts during tests.
This happens because 'simctl' does not properly initialize the simulator for use with the Simulator.app, leading to confusion and failed tests.

Related Concepts

Continuous Integration
Ios Development
Xcode Best Practices