Setup the Woosmap Geofencing SDK using iOS SDK

  1. Install SDK
  2. Dependencies
  3. Initialize SDK

The Woosmap Geofencing SDK allows you to monitor Geofences, track your user’s location and connect with the Woosmap Search and Distance APIs.

Learn how to integrate the iOS SDK below. You can also explore the source code on GitHub to get deeper into it.

Install SDK

You can install the SDK in four different ways. Note that the SDK is small and adds less than 10 MB to your compiled app (less than 3MB to the download size).

We recommend installing the SDK via Swift Package Manager.

Swift Package Manager

To integrate Woosmap Geofencing SDK into your project using Swift Package Manager, you can add the library as a dependency in Xcode (11 and above) – see adding package dependencies to your app on Apple documentation. The package repository URL is:


Install Carthage. To Woosmap Geofencing SDK as a github origin, add the following to your Cartfile:

github "woosmap/woosmap-geofencing-ios-sdk" ~> 1.3.1

Then run carthage update and use the framework in Carthage/Build/<platform>.


Install CocoaPods, a dependency manager for Cocoa projects. If you don’t have an existing Podfile, run pod init in your project directory. Add the following to your Podfile: For usage and installation instructions, visit their website. To integrate Woosmap Geofencing SDK into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'WoosmapGeofencing', :git => ''

Add manually

You can also add the SDK to your project manually.


The SDK depends on two external libraries:

It also requires the Apple’s CoreLocation framework. In your target settings, go to General -> Frameworks, Libraries, and Embedded Content and add CoreLocation if you haven’t already.

The SDK currently supports iOS 10 and higher.

Initialize SDK

To retrieve your user’s location data when your app starts, follow these steps:

First, set delegate of protocol Location in the AppDelegate method.

import UIKit
import CoreLocation
import WoosmapGeofencing

class AppDelegate: UIResponder, UIApplicationDelegate  {

    var window: UIWindow?
    let dataLocation = DataLocation()

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        WoosmapGeofencing.shared.getLocationService().locationServiceDelegate = dataLocation
        if (CLLocationManager.authorizationStatus() != .notDetermined) {
        return true

In order to avoid loosing data, you also need to call startMonitoringInBackground in the proper AppDelegate method:

func applicationDidEnterBackground(_ application: UIApplication) {
    if (CLLocationManager.authorizationStatus() != .notDetermined) {

To keep the SDK up to date with user’s location data, you need to call didBecomeActive in the proper AppDelegate method too.

func applicationDidBecomeActive(_ application: UIApplication) {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. 
    // If the application was previously in the background, optionally refresh the user interface.

The SDK tracks position by default. To disable location collection, just change the value in the settings of the SDK as follows:

WoosmapGeofencing.shared.setTrackingEnable(enable: false)

Finally, to effectively retrieve the location data, add this in your class delegate:

public class DataLocation:LocationServiceDelegate  {
    public init() {}
    public func tracingLocation(location: Location) {
        NSLog("location: \(location)")
    public func tracingLocationDidFailWithError(error: Error) {
    public func readLocations()-> [Location] {
        return Locations.getAll()
    public func eraseLocations() {
Was this article helpful?
Have more questions? Submit a request