Faster iOS Builds with Bazel

Faster iOS Builds with Bazel

TruongThi Doan
LINE App Dev 4 Software Engineer
https://linedevday.linecorp.com/jp/2019/sessions/S2-9

Be4518b119b8eb017625e0ead20f8fe7?s=128

LINE DevDay 2019

November 21, 2019
Tweet

Transcript

  1. 2019 DevDay Faster iOS Builds With Bazel > TruongThi Doan

    > LINE App Dev 4 Software Engineer
  2. Agenda > Problems > Challenges > Room for Improvement

  3. Overview LINE iOS Modules 224 Lines of Code 1.4m Source

    Files 8.4k
  4. Problems > “Works on my machine” problems > Release builds

    must be full clean builds > Long build times as project grows
  5. https://bazel.build Bazel Growing LINE for iOS • Thursday, 14:30 >

    Fast & Reproducible > Remote Caching > Extensible
  6. Incremental Adoption Prebuilt Static Frameworks Ƃ load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") swift_library( name

    = "LineServices", srcs = glob(["*.swift"]), deps = [":Thrift"], )
  7. Incremental Adoption Prebuilt Static Frameworks Ƃ load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_static_framework")

    swift_library( name = "LineServices", srcs = glob(["*.swift"]), deps = [":Thrift"], ) ios_static_framework( name = "LineServicesFramework", bundle_name = "LineServices", minimum_os_version = "11.0", deps = [":LineServices"], )
  8. > Swift dependencies Carthage Git Submodules > Dependencies that aren’t

    directly related to iOS CocoaPods > Objective-C dependencies Dependencies
  9. > Pod2BUILD > Manually writing BUILD files Objective-C static frameworks

    Swift static frameworks > .swiftdoc & .swiftmodule weren’t bundled > Post-processing ios_static_framework() Cont’d Dependencies
  10. Mixed Objective-C & Swift Frameworks

  11. Mixed Targets > Generating module map from Obj-C headers Ƃ

    native.genrule( name = "objc_module_map", srcs = hdrs, outs = ["module.modulemap"], cmd = """ echo "module {} {{" >> $@ for src in $(SRCS); do echo " header \\"$${{src}}\\"" >> $@ done echo "}}" >> $@ """.format(module_name), )
  12. Mixed Targets > Generating module map from Obj-C headers >

    swift_library() with all Swift source files Ƃ native.swift_library( name = "LineServices", module_name = "LineServices", srcs = native.glob(["*.swift"]), copts = [ "-import-underlying-module", "-Xfrontend", "-enable-objc-interop", "-Xcc", "-fmodule-map-file=$(execpath :module.modulemap)", ], swiftc_inputs = hdrs + ["module.modulemap"], features = ["swift.no_generated_module_map"], )
  13. Mixed Targets > Generating module map from Obj-C headers >

    swift_library() with all Swift source files > objc_library() with all Obj-C source files Ƃ native.objc_library( name = "LineServices_umbrella", module_name = "LineServices", hdrs = hdrs, srcs = native.glob(["*.m"]), deps =[":LineServices"], )
  14. Ƃ Local Development > Generating Xcode project from BUILD files

    with Tulsi > Breakpoints work by overriding an LLDB setting # ~/.lldbinit settings set target.source-map "./" "~/line-ios/"
  15. Remote Caching > Any HTTP/1.1 backend > Google Cloud Storage

    > bazel-remote • github.com/buchgr/bazel-remote > Don’t use Bazel 1.1 Ƃ
  16. Clean Build Times No Cache With Cache 0෼ 6෼ 12෼

    18෼ 24෼ 30෼ Bazel Xcode
  17. Room for Improvement > Developer experience > Improving shared remote

    cache > Swift Package Manager support
  18. Thank You