iOS, Bazel and Google Maps & Google Places
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.
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:
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:
To build a Swift library using the Google Maps and Google Places SDKs, is a simple as you can see below:
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.
Google Maps for iOS Samples https://github.com/googlemaps/maps-sdk-for-ios-samples
Google Maps SDK for iOS Documentation: https://developers.google.com/maps/documentation/ios-sdk/intro