# iOS reference (TryYourSize for Swift)

> The native Size guide button (SwiftUI and UIKit), the shopper's recommended size, and the TryYourSize window in a sheet.

Source: https://docs.tryyoursize.com/reference/ios/

*SDK* · `TryYourSize (Swift)` · v0.1.0

iOS 16+, Swift 5.9+, SwiftUI and UIKit. A client per publishable key, the native **Size guide** button, the shopper's recommended size (sizes only), and our window in a sheet. Register your app for the key in Studio as `ios-app://<bundle id>` (test mode today; live mode for apps is coming soon).

## Install

**Swift Package Manager**

```swift
// File → Add Package Dependencies → the TryYourSize package, product "TryYourSize".
// Package.swift:
.product(name: "TryYourSize", package: "TryYourSize")
```

**CocoaPods**

```ruby
pod 'TryYourSize'
```

## Initialize

**Swift**

```swift

let tys = try TryYourSize(publishableKey: "pk_test_…") // a secret key throws
```

**Kotlin**

```kotlin
val tys = TryYourSize(context, "pk_test_…") // a secret key throws
```

**React Native**

```tsx

await configure("pk_test_…"); // once, at startup
```

**Flutter**

```dart

final tys = await TryYourSize.create('pk_test_…');
```

Error codes: [Mobile SDK errors](https://docs.tryyoursize.com/mobile/errors.md).

## Client

| | |
|---|---|
| [`init`](https://docs.tryyoursize.com/reference/ios/init.md) | Creates the client for your publishable key. |
| [`Configuration`](https://docs.tryyoursize.com/reference/ios/configuration.md) | Options of the client. |
| [`recommendation(for:)`](https://docs.tryyoursize.com/reference/ios/recommendation.md) | The shopper's recommended size for a product, in your size labels. |
| [`onRecommendation`](https://docs.tryyoursize.com/reference/ios/on-recommendation.md) | Calls handler now (once known) and on every change: signing in, a new body, a simulation finishing. |
| [`on (events)`](https://docs.tryyoursize.com/reference/ios/on.md) | Window events: ready, open, close, size, loadError. |
| [`present`](https://docs.tryyoursize.com/reference/ios/present.md) | Opens the measuring / try-on window for a product, as a sheet over presenter (default: the app's top-most view controller). |
| [`appearance`](https://docs.tryyoursize.com/reference/ios/appearance-property.md) | Live restyle (e.g. |
| [`appOrigin`](https://docs.tryyoursize.com/reference/ios/app-origin.md) | ios-app://<bundle id>: what the store registers as an allowed origin. |

## Size guide button

| | |
|---|---|
| [`SizeGuide`](https://docs.tryyoursize.com/reference/ios/size-guide.md) | The "Size guide" button: "Size guide" → "Calculating your size…" → "Your size: M". |
| [`SizeGuideButton`](https://docs.tryyoursize.com/reference/ios/size-guide-button.md) | The same button as a UIView. |

## Types

| | |
|---|---|
| [`Recommendation`](https://docs.tryyoursize.com/reference/ios/recommendation-type.md) | The shopper's recommended size for one product, in the store's own size labels. |
| [`Appearance`](https://docs.tryyoursize.com/reference/ios/appearance.md) | Colours, font and corner radius for the button and the window. |
| [`TryYourSizeError`](https://docs.tryyoursize.com/reference/ios/errors.md) | Every error the SDK raises: a stable code, a message and a doc link (like the web SDK). |
