Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Postmortem for switching Lyft's iOS app to Bazel

Keith Smiley
December 11, 2019

Postmortem for switching Lyft's iOS app to Bazel

Details of how we migrated Lyft's iOS codebase to build entirely with bazel presented at BazelCon 2019

Keith Smiley

December 11, 2019
Tweet

More Decks by Keith Smiley

Other Decks in Technology

Transcript

  1. Lyft - 70+ iOS engineers - 2 iOS tooling engineers

    - 800k+ lines of Swift, 0 lines of Objective-C - 5500+ bazel targets
  2. 9.

  3. Exporting Bazel Projects • bazel build --nobuild --aspects <aspect> •

    bazel query --output=xml <query> • bazel cquery --output=proto <query>
  4. Exporting Bazel Projects • bazel build --nobuild --aspects <aspect> •

    bazel query --output=xml <query> • bazel cquery --output=proto <query>
  5. Incremental Migration 1A. Convert to Bazel as the build source

    of truth and build on CI 1B. Generate Xcode projects from Bazel, and build with Xcode
  6. Running & Testing • Copy .app or .xctest to Xcode

    DerivedData (ie "bazel-out") • Xcode does the rest, which helps preserves many IDE features
  7. More to Integrating bazel in Xcode • Installing apps and

    tests • Appease the Xcode build, by copying build artifacts • Supporting the IDE by importing build outputs • Generating debugger settings
  8. Hyrum's Law "With a sufficient number of users of an

    API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody." - Hyrum Wright, Googler
  9. Indexing Facts of Life • Backbone of important IDE features

    • Common developer slowdown • Usually proprietary • Out of band
  10. Indexing Integration • swiftc & clang can produce indexes while

    building • Indexes embed some absolute paths • swiftc & clang and their component libraries are open source • index-import: Purpose built tool for installing indexes into Xcode • https://github.com/lyft/index-import
  11. Debugging, with lldb • Paths have been at the core

    of every challenge • Source paths, binary paths, absolute paths, relative paths, project paths, build paths • Fix by removing paths, or making them relative
  12. Debugging, with lldb • Compiler flags, with the help of

    Bazel wrapped clang, rules_swift worker • Linking locally to ensure the binary has local paths • Empty swift module, locally compiled and bearing embedded debugging options • Generating lldb settings and wiring them into developer's global settings
  13. Focused Subprojects • Generating projects is faster • Launching Xcode

    and time to usability is faster • Provide natural scopes for teams/projects • Performance scales by developer scope, not repo
  14. IDE Finer Details • Native Xcode test experience • Augmented

    project search • Compiler fixits • Full index, not focused index • Refactoring • Remote cache!
  15. Unresolved • Progress bar is useless, build log looks different

    • No background indexing • bazel×swiftc parallelism mismatch • Code coverage features don't work