# Installation

Detour provides a native iOS SDK (`Detour`) for deferred links, Universal Links, and custom scheme links.

:::tip[AI agent skills]
Detour ships two AI coding-agent skills: `detour-onboarding` for a setup from scratch, and `migrate-to-detour` for moving off Branch or AppsFlyer. Both cover this page. See [Detour Skills](https://detour.swmansion.com/docs/platform/fundamentals/skills).
:::

A Detour app in the Dashboard is required before the SDK can resolve links. See [Getting Started](https://detour.swmansion.com/docs/platform/fundamentals/getting-started).

## Requirements

- iOS `13+`
- Swift `5.5+`

## Swift Package Manager

In Xcode:

1. Open your project.
2. Go to `File > Add Package Dependencies...`
3. Enter repository URL:
   - `https://github.com/software-mansion-labs/ios-detour`
4. Add product `Detour` to your app target.

Or in `Package.swift`:

```swift title="Package.swift"
.package(url: "https://github.com/software-mansion-labs/ios-detour", from: "1.1.1")
```

## CocoaPods

In your `Podfile`:

```ruby title="Podfile"
platform :ios, '13.0'

target 'YourAppTarget' do
  use_frameworks!
  pod 'Detour', '1.1.1'
end
```

Then run:

```bash
pod install
```

## Credentials

Both values come from **API configuration** in the Dashboard: the `appID` and the publishable `apiKey`. See [Getting Started](https://detour.swmansion.com/docs/platform/fundamentals/getting-started#api-configuration).

```swift
import Detour

let detourConfig = DetourConfig(
    apiKey: "<YOUR_DETOUR_API_KEY>",
    appID: "<YOUR_DETOUR_APP_ID>",
    shouldUseClipboard: true,
    linkProcessingMode: .all
)
```

Keep `apiKey` and `appID` in a build configuration file or another secure configuration layer rather than hard-coded in source.

## Link capabilities

### Universal Links

In Xcode, open your app target, select **Signing & Capabilities**, add the
**Associated Domains** capability, and enter `applinks:<your-domain>`. Use the
domain generated in
[**App configuration**](https://detour.swmansion.com/docs/platform/fundamentals/getting-started#app-configuration)
in the Dashboard.

The resulting entry in your app's entitlements file is:

```xml title="<App>.entitlements"
<key>com.apple.developer.associated-domains</key>
<array>
  <string>applinks:<your-domain></string>
</array>
```

Without this capability, iOS does not dispatch Detour Universal Links to your
app.

If your app is served from a [custom domain](https://detour.swmansion.com/docs/platform/advanced/custom-domain),
the Dashboard generates this entry for that domain. Assign the domain before
you copy the entry. Changing the host an app is assigned to later needs a new
build.

### Custom-scheme links (optional)

Custom schemes are not generated by the Dashboard. Add your scheme in Xcode
under the app target's **Info** → **URL Types**, or add the equivalent entry to
`Info.plist`:

```xml title="Info.plist"
<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>myapp</string>
    </array>
  </dict>
</array>
```

Without this entry, iOS does not dispatch `myapp://...` links to your app. The
startup and runtime callbacks for both link types are covered in
[Usage](https://detour.swmansion.com/docs/sdk/ios/sdk-usage).

## Privacy manifest

From `1.1.1` the package bundles a `PrivacyInfo.xcprivacy` manifest, copied into
your app by both Swift Package Manager and CocoaPods. There is nothing to
configure. You still need to answer the App Store Connect privacy questionnaire
for what Detour collects. The answers are listed in
[Privacy](https://detour.swmansion.com/docs/sdk/ios/privacy).

## Next steps

1. Wire startup and runtime handling in [Usage](https://detour.swmansion.com/docs/sdk/ios/sdk-usage).
2. Run the template app in [Examples](https://detour.swmansion.com/docs/sdk/ios/examples).