Test & Troubleshoot

Enable Debug Mode

Debug mode allows you to view debug logs for the Pilgrim SDK so you can quickly spot any configuration errors and better understand SDK states. For iOS, there is a method named presentDebugViewController(parentViewController:) in the PilgrimManager that will present a view controller from your current view controller with the debug logs you can display in your host app. Developers who wish to display debug mode can do so with the following implementation instructions:

  1. Configure Pilgrim

You should have already configured Pilgrim in your application’s AppDelegate.

  1. Enable Debugging in AppDelegate

In the didFinishLaunchingWithOptions method where you configured the Pilgrim Manager, add the following line of code:

PilgrimManager.shared().isDebugLogsEnabled = true

This will begin logging and saving debug statements that will be displayed in debug mode.

  1. Present the Debug View Controller

The presentDebugViewController(parentViewController:) method returns a view containing debug mode. You can choose how you’d like to display this (e.g., through a button, a gesture, etc.). Here is an example of how to initialize and present it:

PilgrimManager.shared().presentDebugViewController(parentViewController: self)

Test a Visit

With Pilgrim properly configured, the delegate method(s) should be hit whenever you arrive or depart at one of our 105M+ places around the world. In order to test your visit callback without physically walking around, we provide a testing class visitTester. This class can be used to simulate visits with different confidence levels and location types.

For example, the following code will simulate a visit at a given lat/lng:

PilgrimManager.shared().visitTester.fireTestVisit(location: CLLocation(latitude: 37.7904311, longitude: -122.4066613))

Reasons for a getCurrentLocation nil or error response

There are a couple reasons why calling getCurrentLocation would return an error or a nil value:

  1. Lack of network connectivity: The most likely reason the SDK cannot retrieve the device's current location would be because the API request has failed to make a proper connection to the Foursquare server.

  2. Lack of location permissions: If the LocationSubscriber is not allowed to get location info. This means that the proper location permissions have not been properly set or granted by the user. For foreground usage, the When In Use permissions are required. And if being used in the background, it will require the Location Always permission.

  3. CLLocation timeout: If CLLocation doesn’t return a location to us within the timeout value we specify and fails to resolve a location.

Handle "Unknown Attribute" Errors

You may run into the following two errors if you are building with Xcode 11.3 and earlier

- Unknown attribute ‘_inheritsConvenienceInitializers’
- Unknown attribute ‘_hasMissingDesignatedInitializers’

These errors may occur because of 2 new annotation processing methods rolled out in Swift 5.2, which is used in Xcode 11.5

If you happen to run into those errors, you can perform the following steps to remove the annotations that are causing trouble in the swiftinterface.

  1. Open the target project's Edit Scheme menu.
screenshot showing edit schemescreenshot showing edit scheme
  1. Go to Build > Pre-actions and select the New Run Script Action option at the bottom.
screenshot showing build actionsscreenshot showing build actions
  1. Add the below script to the editor and select the correct target.
screenshot showing add script codescreenshot showing add script code
# CocoaPods
if [ -d "${PROJECT_DIR}/Pods/Pilgrim" ]; then
    find ${PROJECT_DIR}/Pods/Pilgrim/Pilgrim-2*/Pilgrim.framework/Modules/Pilgrim.swiftmodule/ -type f -name '*.swiftinterface' -exec sed -i '' s/'@_inheritsConvenienceInitializers '// {} +
    find ${PROJECT_DIR}/Pods/Pilgrim/Pilgrim-2*/Pilgrim.framework/Modules/Pilgrim.swiftmodule/ -type f -name '*.swiftinterface' -exec sed -i '' s/'@_hasMissingDesignatedInitializers '// {} +
fi
  1. Once the annotations have been removed, you can continue building your project.

Did this page help you?