This document discusses tools and processes for automating development tasks to improve productivity. It describes how the author's team:
Released over 128 versions of their software in 5 years with an average of over 2 releases per month.
Used tools like Fastlane, Xcode, and CocoaPods to automate tasks like continuous integration testing, building for beta distribution and App Store submission, and monitoring build performance and code quality over time.
Optimized their build process through techniques like modularization, reducing dependencies, and enabling compiler optimizations to reduce build times from several minutes to under 2 minutes.
Tracked metrics like build time, warnings, and test coverage in databases like InfluxDB and displayed them in Grafana for
2. DEVELOPMENT TOOLS AT BASE
WHAT
‣ How we worked on improving our build performance
‣ How we automated monitoring high quality standards
‣ How we optimized non-programming tasks
to minimize waiting time
5. DEVELOPMENT TOOLS AT BASE
BASE 3.5.2
BUILD 2259
‣ more than 2 releases per month on average
‣ lengthy projects usually
‣ Base 3.0 took 10 months to develop for 6-9 people
10. DEVELOPMENT TOOLS AT BASE
MEASURING BUILD TIME
‣ display it in Xcode
$ defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES
11. DEVELOPMENT TOOLS AT BASE
IMPROVING BUILD TIME
‣ unused code?
‣ unused dependencies?
‣ package manager
‣ Swift compile time
‣ compiler optimizations
‣ modularization
12. DEVELOPMENT TOOLS AT BASE
IMPROVING BUILD TIME
‣ package manager
➡ CocoaPods adds dependencies’ source (where available)
to your project.
➡ Carthage builds dependencies once and lets you link
your project with compiled frameworks
➡ They don’t know about each other
➡ A general rule: you don’t want >1 dependency manager
It takes 20s to compile Pods in Base
13. ‣ Swift compile time
DEVELOPMENT TOOLS AT BASE
IMPROVING BUILD TIME
-Xfrontend -debug-time-function-bodies
-Xfrontend -warn-long-function-bodies=150
milliseconds
14. ‣ Swift compile time
DEVELOPMENT TOOLS AT BASE
IMPROVING BUILD TIME
-Xfrontend -debug-time-function-bodies
15. ‣ Swift compile time
➡ BuildTimeAnalyzer https://github.com/RobertGummesson/BuildTimeAnalyzer-for-Xcode
DEVELOPMENT TOOLS AT BASE
IMPROVING BUILD TIME
16. ‣ Swift compile time
DEVELOPMENT TOOLS AT BASE
IMPROVING BUILD TIME
-Xfrontend -warn-long-function-bodies=150
milliseconds
17. ‣ Compiler optimizations
➡ Whole Module Optimization https://swift.org/blog/whole-module-optimizations/
➡ smaller binaries
➡ faster compilation
DEVELOPMENT TOOLS AT BASE
IMPROVING BUILD TIME
Source: swift.org
18. ‣ Enabling WMO for debug builds
➡ remember to disable other unrelated optimizations
DEVELOPMENT TOOLS AT BASE
IMPROVING BUILD TIME
!!!
19. ‣ WMO for debug builds — example build time:
➡ No optimization: 184s
➡ Single-File Optimization: 190s
➡ Whole Module Optimization: 123s
DEVELOPMENT TOOLS AT BASE
IMPROVING BUILD TIME
20. ‣ Modularization
➡ Swift module — a set of files that form an independent binary
➡ clearly defined responsibilities
➡ better control of API visibility
➡ reusability
➡ easier to open-source
➡ incremental build time improvement
DEVELOPMENT TOOLS AT BASE
IMPROVING BUILD TIME
21. ‣ Modularization
➡ example approach:
✓ common UI extensions +
simple, reusable UI classes
(cells, custom controls)
✓ general-purpose helper
classes and extensions
DEVELOPMENT TOOLS AT BASE
IMPROVING BUILD TIME
24. ‣ — automating tasks
‣ — continuous integration
‣ — collecting data
‣ — displaying data
DEVELOPMENT TOOLS AT BASE
SETUP
25. ‣ Common tasks
➡ HockeyApp beta builds
➡ AppStore builds
➡ automated unit testing on Jenkins
‣ Uncommon tasks
➡ tracking build time
➡ tracking warning count
➡ tracking code coverage
➡ more
DEVELOPMENT TOOLS AT BASE
FASTLANE
26. ‣ Update submodules + install pods
‣ Clean project, build and run tests using scan
DEVELOPMENT TOOLS AT BASE
FASTLANE - AUTOMATED UNIT TESTS ON CI, SIMPLE FLOW
27. ‣ Update submodules + install pods
‣ Clean project using xcodebuild
‣ build_duration = Time.now
‣ Build for testing using xcodebuild
‣ build_duration = Time.now - build_duration
‣ Extract warning count from the log file:
Dir.chdir("..") do
build_output_path = File.expand_path("xcodebuild.log", buildlog_path)
warning_count = File.foreach(build_output_path).grep(/: warning:/).uniq.count
end
‣ Get build number and version from Info.plist
DEVELOPMENT TOOLS AT BASE
FASTLANE - AUTOMATED UNIT TESTS ON CI
28. ‣ Submit data to InfluxDB
influx(
tags: {
branch: git_branch,
build_number: current_build_number,
version: current_version_name,
scheme: scheme_name
},
values: {
build_duration: build_duration,
warning_count: warning_count
}
)
‣ Run tests :) using scan
‣ Generate code coverage report using slather
DEVELOPMENT TOOLS AT BASE
FASTLANE - AUTOMATED UNIT TESTS ON CI, CONTINUED
33. ‣ Update submodules + install pods
‣ Update AppStore certificate using sigh
‣ Fetch the next available build number from HockeyApp
‣ Clean project, build and archive using gym
‣ Verify and upload archive to AppStore using deliver
‣ Create and push a release commit + tag
‣ Upload debug symbols to HockeyApp
‣ Upload Xcode archive to Dropbox
DEVELOPMENT TOOLS AT BASE
FASTLANE - APPSTORE BUILD