# iOS

## Integration

The Trip Simulator component includes two modules:&#x20;

* The first module  is used as a testing tool for your debug application.
* The second module is a “no-op” module. It will do nothing and does not include any trip data: it’s an empty implementation that mirrors the public methods and objects of the first module which can be integrated into your release-mode application to maintain a consistent codebase across both debug and release modes without embedding the real trip simulator in production.

To add the Trip Simulator module to your app:

* **Swift Package Manager:** Add '`DriveKitTripSimulator`' from repository: `https://github.com/DriveQuantPublic/drivekit-sdk-spm.git` as dependency and '`DriveKitTripSimulatorNoop`' module in release if you need it.
* **Cocoapods** (deprecation scheduled for the end of 2025): add the following lines to your dependencies in your Podfile, with the no-op module in release mode if you need it:

```swift
pod 'DriveKitTripSimulator', :configuration => ['Debug']
pod 'DriveKitTripSimulatorNoop', :configuration => ['Release']
```

## **Usage**

DriveQuant offers the possibility of running simulations from a list of preset trips. After integrating and activating the trip simulation component, you can select a preset trip from those described in the table below. Once the simulation is launched, the Trip Analysis SDK will receive the configured callbacks automatically.

<table data-header-hidden><thead><tr><th width="298.71428571428567">Name</th><th width="120">Duration (s)</th><th width="126">Distance (m)</th><th>Description</th></tr></thead><tbody><tr><td>Name</td><td>Duration</td><td>Distance</td><td>Description</td></tr><tr><td><code>shortTrip</code> </td><td>8 min</td><td>2 km</td><td>Trip too short that does not allow to rate the driver's behavior</td></tr><tr><td><code>mixedTrip</code> </td><td>15 min</td><td>12 km</td><td>A 15-minute mixed trip in urban and suburban areas</td></tr><tr><td><code>cityTrip</code> </td><td>20 min</td><td>8 km</td><td>A 20-minute city trip </td></tr><tr><td><code>suburbanTrip</code> </td><td>30 min</td><td>30 km</td><td>A 30-minute trip performed in a suburban environment mostly</td></tr><tr><td><code>highwayTrip</code> </td><td>55 min</td><td>100 km</td><td>A 55-minute highway trip </td></tr><tr><td><code>trainTrip</code> </td><td>10 min</td><td>5 km</td><td>Trip recorded in a train to test the alternative transportation modes detection</td></tr><tr><td><code>busTrip</code></td><td>13 min</td><td>3 km</td><td>Trip recorded in a bus to test the alternative transportation modes detection</td></tr><tr><td><code>boatTrip</code></td><td>40 min</td><td>25 km</td><td>Trip recorded in a boat to test the alternative transportation modes detection</td></tr><tr><td><code>tripWithCrash</code></td><td>5 min</td><td>1 km</td><td>A trip to simulate an unconfirmed or a confirmed crash.</td></tr><tr><td><code>tripWithCrashStillDriving</code></td><td>23 min</td><td>24 km</td><td>A trip to simulate an accident confirmed less than two minutes after the start of the trip, after which the driver continued driving.</td></tr></tbody></table>

### Check if it’s the no-op module

To verify if you are embedding the no-op module, you can call the following code:

```swift
let isNoop = DriveKitTripSimulator.shared.isNoop
```

### **Simulate a trip**

To simulate a trip, you just need to send the selected trip to the `start` method:

```swift
import DriveKitTripSimulatorModule

DriveKitTripSimulator.shared.start(<The_PresetTrip_you_want>)
```

### **Stop the simulation**

To stop the simulation of a trip, you need to call the `stop` method:

```swift
import DriveKitTripSimulatorModule

DriveKitTripSimulator.shared.stop()
```

### Simulate a crash during a trip

{% hint style="warning" %}
The simulation of a trip with a collision only works on a real device, not with the simulator.
{% endhint %}

In order to mock a crash to check your integration, you must call the `startCrashTrip` function with a `PresetCrashConfiguration` item as parameter. Possible values for PresetCrashConfiguration enumeration are described in the table below:

<table><thead><tr><th width="179.78978549715043">Name</th><th>Description</th></tr></thead><tbody><tr><td><code>confirmed40KmH</code></td><td>A short trip with a collision at 40 km/h that occurs 132 seconds after the trip begins and that corresponds to a confirmed accident.</td></tr><tr><td><code>confirmed30KmH</code></td><td>A short trip with a collision at 30 km/h that occurs 137 seconds after the trip begins and that corresponds to a confirmed accident.</td></tr><tr><td><code>confirmed20KmH</code></td><td>A short trip with a collision at 20 km/h that occurs 141 seconds after the trip begins and that corresponds to a confirmed accident.</td></tr><tr><td><code>unconfirmed0KmH</code></td><td>A short trip with a collision during a vehicle stop that occurs 159 seconds after the trip begins and that corresponds to an unconfirmed accident.</td></tr><tr><td><code>confirmed30KmHStillDriving</code></td><td>A trip to with a collision at 30km/h that occurs 95 seconds after the trip begins and that corresponds to a confirmed accident, after which the driver continue driving.</td></tr></tbody></table>

```swift
DriveKitTripSimulator.shared.startCrashTrip(.confirmed20KmH)
```
