iOS, Bazel and Google Maps & Google Places

Gonzalo Ruiz de Villa
2 min readApr 2, 2020

If you need to use Google Maps in your iOS application and you are using Bazel.build to build it, then this configurations I used may save you some time.

I solved in three steps:

  • Add remote http archives.
  • For each remote, we define a BUILD file that will be executed inside the folders where downloaded code expand
  • We add the needed references in the swift libraries that use the Google Maps and Google Places SDK.

The WORKSPACE file need the following lines. Of course, if you are not using Google Places, you can remove the corresponding lines.

WORKSPACE

As you can see, the build_file parameter points to the BUILD file that will need to be executed to register the libraries within Bazel to be able to add them as target dependencies of the swift libraries you will want to develop.

The first one, GoogleMaps/BUILD looks like this:

GoogleMaps/BUILD

The GoogleMaps static import needs to reference the frameworks mentioned in Google Maps documentation (https://developers.google.com/maps/documentation/ios-sdk/start?hl=es)

The second BUILD, for Google Places looks like this:

GooglePlaces/BUILD

To build a Swift library using the Google Maps and Google Places SDKs, is a simple as you can see below:

BUILD

You can see in the previous code how we are referencing Google Maps and Google Places using the corresponding labels in de deps attribute.

And with these snippets, you will be able to compile, for instance, the demo code provided by Google:

I hope this suggestions help you save some time when trying to integrate Google Maps in you Bazel built iOS application.

--

--

Gonzalo Ruiz de Villa

Engineer, Google Developer Expert , co-founder of Adesis Netlife, Chlydro and Kenobi Ventures. CTO @ GFT Group