Installation
Detour provides a native iOS SDK (Detour) for deferred links, Universal Links, and custom scheme links.
A Detour app in the Dashboard is required before the SDK can resolve links. See Getting Started.
Requirements
Section titled “Requirements”- iOS
13+ - Swift
5.5+
Swift Package Manager
Section titled “Swift Package Manager”In Xcode:
- Open your project.
- Go to
File > Add Package Dependencies... - Enter repository URL:
https://github.com/software-mansion-labs/ios-detour
- Add product
Detourto your app target.
Or in Package.swift:
.package(url: "https://github.com/software-mansion-labs/ios-detour", from: "1.1.1")CocoaPods
Section titled “CocoaPods”In your Podfile:
platform :ios, '13.0'
target 'YourAppTarget' do use_frameworks! pod 'Detour', '1.1.1'endThen run:
pod installCredentials
Section titled “Credentials”Both values come from API configuration in the Dashboard: the appID and the publishable apiKey. See Getting Started.
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
Section titled “Link capabilities”Universal Links
Section titled “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
in the Dashboard.
The resulting entry in your app’s entitlements file is:
<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, 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)
Section titled “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:
<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.
Privacy manifest
Section titled “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.