> For the complete documentation index, see [llms.txt](https://docs.idlayr.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.idlayr.com/get-started/sdks/ios.md).

# iOS SDK

{% hint style="info" %}
**iOS** · Swift · `IDlayrKit`
{% endhint %}

`IDlayrKit` is IDlayr's iOS SDK. It powers the device-side half of the two device APIs that require carrier-pinned cellular routing — **Secure SNA** and **Discovery** — by pinning the verification request to the cellular interface and surfacing client-side errors in a predictable shape.

Reverse SMS is **not covered by this SDK**. Its device-side step is your app opening the native SMS composer via a `sms:` URL — see [Reverse SMS integration](/products/number-verification/reverse-sms/integration.md).

|                    |                                                                                 |
| ------------------ | ------------------------------------------------------------------------------- |
| Package name       | `IDlayrKit`                                                                     |
| Latest version     | **2.4.1** (2026-03-04)                                                          |
| Language           | Swift 5.9                                                                       |
| Minimum iOS        | 13                                                                              |
| Distribution       | Cloudsmith Swift Package Registry (SPM) or Cloudsmith CocoaPods Specs (private) |
| Supported products | Secure SNA, Discovery                                                           |
| Versioning         | SemVer — see [SDK versioning](/get-started/sdks/versioning.md)                  |

## 1. Install the SDK

You'll need a **Cloudsmith entitlement token** before either install path will work. The token is shared by your IDlayr account team during onboarding. Store it as a build-time secret (e.g. `CLOUDSMITH_TOKEN` in your CI). Never check it into source control or include it in a published `.ipa`.

### Swift Package Manager

Add `IDlayrKit` as a Swift package, pointing at IDlayr's private Cloudsmith Swift Package Registry:

```
https://swift.cloudsmith.io/idlayr/sdk-ios-swift/
```

Authenticate the registry with your Cloudsmith entitlement token. Xcode's package authentication dialog accepts the token as a password; in CI, configure netrc or pass the token via `xcodebuild -authenticationKeyPath`.

### CocoaPods

Add IDlayr's private CocoaPods Specs repository to your `Podfile`:

```ruby
source 'https://dl.cloudsmith.io/<entitlement-token>/idlayr/sdk-ios-cocoapods/cocoapods/index.git'
source 'https://cdn.cocoapods.org/'

platform :ios, '13.0'
use_frameworks!

target 'YourApp' do
  pod 'IDlayrKit'
end
```

Substitute `<entitlement-token>` from your build environment.

## 2. Import and use

```swift
import IDlayrKit

let sdk = IDlayrSDK()
```

There is **no `initializeSdk(...)` call**. `IDlayrSDK` is the entry point; instantiate it where you need it.

The exact method names depend on the product:

* **Secure SNA** — pass the verification URL to the SDK's Secure SNA method; the SDK follows the URL's redirect chain on cellular. No access token is needed by the SDK. See [Secure SNA iOS integration](/products/number-verification/secure-sna/integration/ios.md) for the exact method signature and a worked example.
* **Discovery** — see [Discovery iOS integration](/products/number-verification/discovery/integration/ios.md).

The per-product integration pages are the source of truth for SDK signatures. This page covers cross-cutting setup.

## 3. Cellular pinning

For Secure SNA and Discovery to work, the SDK has to send the verification request **specifically over the cellular data path** — Wi-Fi breaks the carrier's ability to verify the SIM. `IDlayrKit` uses Apple's `NWConnection` (from the `Network` framework) to pin the request to the cellular interface even when the device is also on Wi-Fi.

You don't need to configure this. The SDK handles it internally.

If the device has **no cellular data path at all** (airplane mode, eSIM not provisioned, or a Wi-Fi-only iPad), the SDK returns `sdk_no_data_connectivity` and never attempts the request. Fall back to an alternate verification path in your app — for example, [Reverse SMS](/products/number-verification/reverse-sms.md), which works without cellular data and doesn't require the SDK at all.

## 4. 2G blocking

The SDK refuses to operate over insecure 2G networks (GPRS, EDGE, CDMA, 1xRTT, IDEN). Calls on a 2G connection return an error code so your app can fall back gracefully. 2G detection and blocking shipped in v2.3.0 (`NetworkError.twoGNetworkDetected` / `sdk_2G_blocked_error`); the `isRunningOn2G()` query is available as part of the public API from v2.4.0 onwards, so your app can pre-check the radio access technology before attempting a verification.

## 5. Sandbox vs production

Sandbox is a **project mode**, not a separate SDK. The same `IDlayrKit` binary handles both — sandbox behaviour is driven by the project credentials your backend uses to mint the access token. See [Project modes](/get-started/concepts/project-modes.md).

{% hint style="warning" %}
**Sandbox on iOS requires Wi-Fi** (from v2.4.0). In production, the SDK forces cellular; in sandbox, the SDK expects Wi-Fi so simulated verifications can run on devices that aren't on real cellular networks. If sandbox calls fail on a cellular device, switching to Wi-Fi is the fix.
{% endhint %}

## 6. SDK errors

`IDlayrKit` returns errors in the completion handler's response dictionary, under the `error` and `error_description` keys. These are **client-side errors** raised before any HTTP request reaches IDlayr (or while the SDK processes a response locally) — they are not HTTP errors and have no RFC 7807 representation.

See [SDK errors](/get-started/sdks/errors.md) for the full cross-platform catalogue, the recommended action per code, and the difference between an SDK error and an API error. For server-side / HTTP errors (RFC 7807) returned during the same verification, see the per-product error pages — e.g. [Secure SNA error codes](/products/number-verification/secure-sna/error-codes.md).

## 7. Migrating from `tru-sdk-ios`

| Legacy (`tru-sdk-ios`)                | v1 (`IDlayrKit`)                                                       |
| ------------------------------------- | ---------------------------------------------------------------------- |
| Public Swift Package Manager          | Private Cloudsmith Swift Package Registry (entitlement token required) |
| Public CocoaPods (default specs repo) | Private Cloudsmith CocoaPods Specs (entitlement token required)        |
| `import TruSDK`                       | `import IDlayrKit`                                                     |
| Class names prefixed `Tru…`           | Class names prefixed `IDlayr…`                                         |

There is no compatibility shim — migration is a one-time change of dependency, import, and class names. See the SDK migration guide in Help Center for a full walkthrough.

## 8. Where to find the current version

The current iOS SDK version is published on Cloudsmith and CocoaPods. iOS versions independently of Android — see [SDK versioning](/get-started/sdks/versioning.md). For release notes, see the [Changelog](https://docs.idlayr.com/changelog).


---

# 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.idlayr.com/get-started/sdks/ios.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.
