Skip to content

iOS reference (TryYourSize for Swift)

SDKTryYourSize (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).

// File → Add Package Dependencies → the TryYourSize package, product "TryYourSize".
// Package.swift:
.product(name: "TryYourSize", package: "TryYourSize")
import TryYourSize
let tys = try TryYourSize(publishableKey: "pk_test_…") // a secret key throws

Error codes: Mobile SDK errors.

init Creates the client for your publishable key.
Configuration Options of the client.
recommendation(for:) The shopper’s recommended size for a product, in your size labels.
onRecommendation Calls handler now (once known) and on every change: signing in, a new body, a simulation finishing.
on (events) Window events: ready, open, close, size, loadError.
present Opens the measuring / try-on window for a product, as a sheet over presenter (default: the app’s top-most view controller).
appearance Live restyle (e.g.
appOrigin ios-app://<bundle id>: what the store registers as an allowed origin.
SizeGuide The “Size guide” button: “Size guide” → “Calculating your size…” → “Your size: M”.
SizeGuideButton The same button as a UIView.
Recommendation The shopper’s recommended size for one product, in the store’s own size labels.
Appearance Colours, font and corner radius for the button and the window.
TryYourSizeError Every error the SDK raises: a stable code, a message and a doc link (like the web SDK).

Was this page helpful?