Search code examples
swiftgoogle-mapsgoogle-maps-markersmarkerclusterer

Google Marker Clustering. How to add this lib to project? Swift


There are multiple instructions on installing Google Marker Clustering library, e.g: https://developers.google.com/maps/documentation/ios-sdk/utility/setup https://github.com/googlemaps/google-maps-ios-utils/blob/master/Swift.md

But non of them didn't work for me. Also, they have some contradictions. I tried to add pod, tried to add bridging file etc. My "import" doesn't know about anything like clustering

How can I make it work?


Solution

  • I found the way to fix this issue. After adding files as Google provided in it's guide, do this steps:

    1. Create file "AppName-Bridging-Header.h".
    2. Import new libraries like so:

      #ifndef Bridging_Header_h

      #define Bridging_Header_h

      #import "GMUMarkerClustering.h"

      #import "GMUGeoJSONParser.h"

      #import "GMUKMLParser.h"

      #import "GMUGeometryRenderer.h"

      #endif /* Bridging_Header_h */

    3. Go to project settings.

    4. Chose "Targets" field and "Build settings" menu.
    5. Search for "Swift compiler" setting.
    6. Add setting "Objective-c bridging header" and path to your file, in my case: "AppName/App/AppName-Bridging-Header.henter image description here

    Done! You have this clustering library in your app.