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

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

LINE DevDay 2019

November 21, 2019
Tweet

More Decks by LINE DevDay 2019

Other Decks in Technology

Transcript

  1. Problems > “Works on my machine” problems > Release builds

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

    Fast & Reproducible > Remote Caching > Extensible
  3. 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"], )
  4. > Swift dependencies Carthage Git Submodules > Dependencies that aren’t

    directly related to iOS CocoaPods > Objective-C dependencies Dependencies
  5. > 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
  6. 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), )
  7. 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"], )
  8. 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"], )
  9. Ƃ 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/"
  10. Remote Caching > Any HTTP/1.1 backend > Google Cloud Storage

    > bazel-remote • github.com/buchgr/bazel-remote > Don’t use Bazel 1.1 Ƃ