What you’ll build
In this quickstart you will:- Install the Desmo iOS SDK via Swift Package Manager.
- Initialize the SDK with your publishable key.
- Start and stop a delivery session from your app.
pk_....If you don’t have a key yet, contact your Desmo representative to have one issued for your project.
Requirements
- iOS 15.0 or later
- Xcode 15 or later
- Swift 5.9 or later
App permissions
To let Desmo record sessions correctly, your app should request:- Location – so sessions can be tied to where the delivery happened.
- Motion & Fitness – so Desmo can interpret movement patterns during the session.
Info.plist with user-facing explanations that match your product:
1. Install the SDK (Swift Package Manager)
You can add the SDK either through Xcode or by editing your ownPackage.swift.
Option 1 – Add via Xcode UI
- In Xcode, open your app project.
- Go to File → Add Package Dependencies…
-
In the search field, paste the package URL:
-
When prompted for Dependency Rule, choose:
- Version → “Up to Next Major”
- Starting from:
1.0.2
-
Select the product
DesmoTraceSDKfor your app target and finish.
Option 2 – Add to Package.swift
If you use SwiftPM directly, add this to your app’s Package.swift:
2. Initialize the SDK
CallDesmo.setup once at app startup, usually in your App’s init or in your AppDelegate.
key: your publishable Desmo API key (starts withpk_).environment:.sandbox– Desmo sandbox environment..live– Desmo production environment.
Desmo.setup fails (for example, if the key does not start with pk_), the SDK will log an error and Desmo.shared will remain nil.
3. Request permissions
The SDK provides a helper to request all required permissions upfront. Call this during your app’s onboarding or before starting the first session:Requesting permissions upfront ensures sensor data flows immediately when a session starts. If you skip this step, the SDK will request permissions during
startSession(), but the first few seconds of data may be missing while the user responds to the prompts.4. Understanding session types
Every session requires a session type that indicates what the driver is doing:| SessionType | When to use |
|---|---|
.pickup | Driver is collecting a package from a merchant/warehouse |
.drop | Driver is delivering a package to a customer |
.transit | Driver is traveling between stops (no specific address) |
For
.pickup and .drop sessions, you must provide an address. For .transit sessions, the address is optional.5. Understanding the Address model
The SDK provides a structuredAddress model for delivery locations:
6. Start a delivery session
Call this when you begin recording a delivery (for example, when the driver starts a drop-off):Required parameters
| Parameter | Type | Description |
|---|---|---|
deliveryId | String | Your internal delivery/order identifier |
sessionType | SessionType | .pickup, .drop, or .transit |
Optional parameters
| Parameter | Type | Description |
|---|---|---|
address | Address? | Delivery address (required for .pickup/.drop, optional for .transit) |
externalRiderId | String? | Your system’s driver/rider ID |
startLocation | StartLocation? | Override the starting GPS position (auto-captured if not provided) |
Full example with all parameters
- Calls Desmo’s backend to create a session.
- Starts collecting telemetry on-device (IMU, GPS, barometer, magnetometer).
- Begins batching telemetry to Desmo while the session is recording.
- Persists data locally if offline and retries when connectivity returns.
7. Stop a delivery session
Call this when the delivery is complete:- Flushes any remaining telemetry.
- Notifies the backend that the session is complete.
- Lets Desmo’s workers start processing PoD intelligence for that session.
Next steps
From here:- Configure keys and environments in Auth & Environments.
- Enable logging and troubleshoot in Logging, Debugging & Troubleshooting.
- Revisit the Desmo Integration Overview at Integrating Desmo to see how the iOS SDK fits with your backend APIs and dashboard.