> For the complete documentation index, see [llms.txt](https://docs.multiset.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.multiset.ai/native-sdk/ios-swift-native.md).

# iOS Swift Native

Add VPS localization and object tracking to an iOS app with the MultiSet Swift SDK, including quick start, requirements and token renewal.

## Overview

The MultiSet iOS SDK provides Visual Positioning System (VPS) localization capabilities for iOS applications. It enables precise indoor and outdoor localization using camera-based visual recognition against pre-mapped 3D environments.

**GitHub Repository:** <https://github.com/MultiSet-AI/multiset-ios-sdk.git>

## Table of Contents

### Sample Views

* [LandingView](/native-sdk/ios-swift-native/sample-views/landingview.md) - Authentication, SDK initialization, and navigation
* [ARLocalizationView](/native-sdk/ios-swift-native/sample-views/arlocalizationview.md) - AR localization (Single-frame and Multi-frame)
* [ARObjectTrackingView](/native-sdk/ios-swift-native/sample-views/arobjecttrackingview.md) - AR object tracking with outline mesh rendering

### API Reference

* [MultiSetConfig](/native-sdk/ios-swift-native/api-reference/multisetconfig.md) - Configuration parameters
* [MultiSetCallback](/native-sdk/ios-swift-native/api-reference/multisetcallback.md) - SDK event callbacks and `FalsePositiveInfo`
* [LocalizationResult](/native-sdk/ios-swift-native/api-reference/localizationresult.md) - Pose data, `GeoCoordinates` and `GeoPose`

## Quick Start

The sample project comes pre-configured with the SDK framework and all necessary dependencies. Follow these steps to get up and running:

### 1. Clone the Repository

```bash
git clone https://github.com/MultiSet-AI/multiset-ios-sdk.git
cd multiset-ios-sdk
```

### 2. Open the Project

Open the `.xcodeproj` file in Xcode.

### 3. Configure Credentials

Open `SDKConfig.swift` and replace the placeholder values with your credentials:

```swift
struct SDKConfig {
    // API Environment
    static let baseURL = MultiSetConfig.productionBaseURL

    // Authentication Credentials
    static let clientId = "YOUR_CLIENT_ID"
    static let clientSecret = "YOUR_CLIENT_SECRET"

    // Map Configuration (use either mapCode OR mapSetCode)
    static let mapCode = "YOUR_MAP_CODE"
    static let mapSetCode = ""

    // Object Tracking Configuration (max 10 codes)
    static let objectCodes: [String] = []
}
```

| Property       | Description                            | Required                 |
| -------------- | -------------------------------------- | ------------------------ |
| `baseURL`      | API host, defaults to production       | No                       |
| `clientId`     | Your client identifier                 | Yes                      |
| `clientSecret` | Your secret key                        | Yes                      |
| `mapCode`      | Single map identifier                  | One of these is required |
| `mapSetCode`   | MapSet identifier                      | One of these is required |
| `objectCodes`  | Codes to track in object tracking mode | Only for object tracking |

To obtain credentials, visit: <https://developer.multiset.ai/credentials>

### 4. Build and Run

1. Select your target iOS device (AR requires a physical device)
2. Press **Cmd + R** to build and run
3. The app opens on the [LandingView](/native-sdk/ios-swift-native/sample-views/landingview.md), where the SDK authenticates automatically
4. **Localization:** Select a mode (Single-Frame or Multi-Frame) and tap **Start Localization** to enter [ARLocalizationView](/native-sdk/ios-swift-native/sample-views/arlocalizationview.md)
5. **Object Tracking:** Tap **Start Object Tracking** to enter [ARObjectTrackingView](/native-sdk/ios-swift-native/sample-views/arobjecttrackingview.md)

## Requirements

* iOS 16.0+
* ARKit compatible device (iPhone 6s or later)
* Camera permission
* Internet connectivity

## API Environment

Every endpoint the SDK calls is built from `MultiSetConfig.baseURL`, which defaults to the production API at `https://api.multiset.ai`. Override it to point a build at a staging, on-premise or proxied deployment:

```swift
var config = SDKConfig.buildConfig()
config.baseURL = "https://staging-api.multiset.ai"   // no trailing slash needed

MultiSet.shared.initialize(config: config, callback: delegate)
```

The value is applied at `initialize(config:callback:)`, before authentication. An access token is only valid against the host that issued it, so switching environments later requires `release()` followed by a fresh `initialize(...)`. Read `MultiSet.shared.activeBaseURL` to see which host requests are going to.

## Session Length and Token Renewal

Access tokens issued by the MultiSet API are short-lived, measured in minutes rather than hours. The SDK renews them for you: it reads each token's own lifetime, refreshes ahead of expiry, and if a request is rejected with HTTP 401 it refreshes once and replays that request. Concurrent requests share a single renewal rather than each triggering their own.

Nothing is required of your app, and sessions of any length work without re-initializing. Two consequences are worth knowing:

* `MultiSet.shared.authToken` changes during a session. Read it at the point of use and never cache it.
* If renewal ultimately fails, for example because credentials were revoked mid-session, the error surfaces through the operation that was in flight (`onLocalizationFailure` or `onObjectTrackingFailure`) with the authentication error in its message. `MultiSet.shared.isAuthenticated` remains `true`.

## Handling False Positives

In visually repetitive spaces the server can return a confident pose for the wrong location, which the user sees as the mesh jumping several metres. Enabling the pose consistency check makes the SDK compare each result against the device's own AR trajectory and discard results that contradict it:

```swift
var config = SDKConfig.buildConfig()
config.poseConsistencyCheck = true
config.poseConsistencyThreshold = 10   // metres, valid range 3 to 30
```

A discarded result leaves the AR scene untouched and calls [`onLocalizationFalsePositive(info:)`](/native-sdk/ios-swift-native/api-reference/multisetcallback.md) instead of `onLocalizationSuccess`. See [Pose Consistency Settings](/native-sdk/ios-swift-native/api-reference/multisetconfig.md#pose-consistency-settings) for tuning guidance.

## Info.plist Configuration

Add the following keys to your `Info.plist`:

```xml
<key>NSCameraUsageDescription</key>
<string>Camera access is required for AR localization</string>

<key>NSLocationWhenInUseUsageDescription</key>
<string>Location access improves localization accuracy</string>
```

## License

Copyright (c) 2026 MultiSet AI. All rights reserved. Licensed under the MultiSet License. For license details, visit [www.multiset.ai](https://www.multiset.ai).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.multiset.ai/native-sdk/ios-swift-native.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
