## Enable Debug Mode

Debug mode allows you to view debug logs for the Movement 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 `MovementSdkManager` 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 the SDK**

You should have already configured the Movement SDK in your application's **AppDelegate**.

2. **Enable Debugging in AppDelegate**

In the `didFinishLaunchingWithOptions` method where you configured the `MovementSdkManager`, add the following line of code:

```swift
   MovementSdkManager.shared().isDebugLogsEnabled = true
   ```

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

3. **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:

```swift
   MovementSdkManager.shared().presentDebugViewController(parentViewController: self)
   ```

## Test a Visit

With the SDK 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:

```swift
MovementSdkManager.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](https://docs.foursquare.com/developer/docs/movement-sdk-ios-test-troubleshoot#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.
