A Comprehensive guide to build a cross-platform application by Bazel

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • bazel.xplatform

  • In this quick guide, we are going to use Bazel to build multiple applications which share a native library. We will be targeting 4 platforms: iOS, macOS, Android and Web. In the end you should have a solid basement to build your first cross-platform application (or move an existing project to Bazel). I listed the project on Github - I encourage you to clone it and experiment.

  • Bazel

    a fast, scalable, multi-language and extensible build system

  • Android NDK 21. NDK v21 is currently the latest supported version

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • rules_apple

    Bazel rules to build apps for Apple platforms.

  • git_repository( name = "build_bazel_rules_apple", remote = "https://github.com/bazelbuild/rules_apple.git", tag = "1.1.3", ) git_repository( name = "build_bazel_rules_swift", remote = "https://github.com/bazelbuild/rules_swift.git", tag = "1.2.0", ) load("@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies") swift_rules_dependencies()

  • rules_swift

    Bazel rules to build Swift on Apple and Linux platforms

  • git_repository( name = "build_bazel_rules_apple", remote = "https://github.com/bazelbuild/rules_apple.git", tag = "1.1.3", ) git_repository( name = "build_bazel_rules_swift", remote = "https://github.com/bazelbuild/rules_swift.git", tag = "1.2.0", ) load("@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies") swift_rules_dependencies()

  • rules_android

    Android rules for Bazel

  • git_repository( name = "build_bazel_rules_android", remote = "https://github.com/bazelbuild/rules_android.git", tag = "v0.1.1", ) android_sdk_repository( name = "androidsdk", path = "", ) android_ndk_repository( name = "androidndk", api_level = 21, path = "", )

  • rules_android_ndk

  • These attributes are not listed in any Bazel tutorial I found! If you omit those, linker will simply drop the symbols, making the library empty. This was raised to Bazel community and eventually should be fixed in a new rule.

  • rules_jvm_external

    Bazel rules to resolve, fetch and export Maven artifacts

  • git_repository( name = "rules_jvm_external", remote = "https://github.com/bazelbuild/rules_jvm_external.git", tag = "4.2", ) load("@rules_jvm_external//:defs.bzl", "maven_install") maven_install( artifacts = [ "androidx.appcompat:appcompat:1.3.0", "com.google.android.material:material:1.4.0", "androidx.constraintlayout:constraintlayout:2.0.4", ], repositories = [ "https://maven.google.com", ], )

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • emsdk

    Emscripten SDK

  • git_repository( name = "emsdk", remote = "https://github.com/emscripten-core/emsdk.git", strip_prefix = "bazel", tag = "3.1.25", ) load("@emsdk//:deps.bzl", "deps") deps() load("@emsdk//:emscripten_deps.bzl", "emscripten_deps") emscripten_deps()

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts