Installation
This process needs to be followed only once, the first time you need to install the SDK in your project. To update the SDK later, in Xcode choose File > Packages > Update to Latest Package Versions (see the version history).
- Add the following package: https://github.com/KlipFit/kleep-spm
- Change dependency rule to: up to next major version
Permissions
Add the following permission to your project on info.plist: NSCameraUsageDescription It is only needed for the body scan. With
isBodyScanEnabled: false (iOS SDK 4.5.0 or later), the SDK never asks for camera access, so the app does not need the key at runtime. App Store Connect checks the binary when you upload a build: if it asks for the key because the SDK contains camera code, keep it.
Usage
Retailer identifier
retailerName is the identifier (UUID) of your retailer account, given by your Kleep account manager. It is not the name of your company.
Kleep creates one retailer account per environment, so you receive one identifier for your test catalogue and one for production. The identifier is the only thing that selects the environment: both use the same SDK and the same API. Pass the same value to requestSize and loadView.
If the identifier is empty or unknown, every product is reported as not supported (.notSupported) and the CTA never shows.
Body scan
By default, the morphology screen offers two ways to get a size: answer the questionnaire, or scan the body with the phone camera. PassisBodyScanEnabled: false to loadView to offer the questionnaire only (iOS SDK 4.5.0 or later):
- the “scan” button is not shown, and no screen leads to the camera;
- the SDK never asks for camera access, so the camera permission prompt never shows (see Permissions).
true, so existing integrations keep the scan.
Size guide journeys
The size guide shows the questions of the product’s category. Kleep decides the journey from your catalogue and your account settings: there is nothing to pass.requestSize and loadView work the same way for every journey. A category not enabled for your account returns .notSupported.
Shopper profiles
From 4.6.0, the SDK keeps one profile per category and, for clothing, one per gender:- going from clothing to shoes and back keeps both profiles;
- a men’s profile never gives a size on a women’s product, and the reverse:
requestSizereturns.noRecommendationYetuntil the shopper answers for that gender. The new form starts empty; - a unisex product, or one without gender, uses the last clothing profile.
Method 1: requestSize
This method allows to implement the logic of the CTA.
Logic schema
This schema explains how to update the CTA opening Kleep.
https://www.figma.com/board/BlurZ01lR3JBQZeTUU98TE/Mobile---CTA-Logic?node-id=0-1&t=ccXWciNziIdfhgew-1
Implementation example
Method 2: loadView
This method is called when the CTA is clicked. It allows to load the different screens. The developper integrating the SDK should embed them into a bottom sheet.
Implementation example
KlipftNavigationController the way you like: SwiftUI .sheet, or .pageSheet, .fullScreen or .overFullScreen in UIKit, including on top of another modal. The size guide stays inside the safe area and draws its own navigation bar (back and close): there is nothing to hide or configure. Requires SDK 4.3.0 or later.
The SDK currently supports 12 UI languages, passed as language: KleepLanguageCode:
Supported languages (12)
Supported languages (12)
.fr— French (default).en— English.enUS— US English.de— German.el— Greek.es— Spanish.it— Italian.ja— Japanese.ko— Korean.nl— Dutch.pt— Portuguese.ru— Russian
.de, .el, .ja, .ko, .ru and .enUS require SDK 4.4.0 or later..enUS shows the English texts with US units selected by default: height in ft/in, weight in lbs and US bra sizes. Shoppers can still switch units.These are language codes, not country codes: Greek is .el (not GR), Japanese is .ja (not JP) and Korean is .ko (not KR).If you use an exhaustive switch over KleepLanguageCode, add a default branch or the new cases.If a language you need isn’t in the list, contact your Kleep representative.Similar products
When the size the shopper selects on the result is out of stock, the size guide can show similar products available in that size, so that your app opens its own product page with that size selected. The SDK never opens a web page: similar products are shown only when you passonSimilarProductSelected, and only the ones Kleep returns with their reference.
To open the product page of your app instead, with the size already selected, pass onSimilarProductSelected to loadView (4.7.0 or later). When the shopper taps a similar product, the SDK closes the size guide, then calls your handler on the main thread with a KleepSimilarProduct:
ProductViewController(productID:selectedVariantID:) and addToCart(variantID:) stand for your own code. In SwiftUI, pass the handler through your UIViewControllerRepresentable the same way as onResult, and update the navigation state that shows your product page.
- The size guide is already dismissed when the handler runs: present or push the product page from the screen that showed the size guide.
- If you embed the size guide instead of presenting it, there is nothing to dismiss: the handler runs at once and your app removes the size guide.
- A similar product that Kleep returns without its reference is not shown.
- Without the handler, the result shows no similar products. Before 4.7.0, a tap opened the product’s web page.
Method 3: track
This method allows to track custom events.
requestSize or loadView. From 4.6.0 they are kept across app launches, so a purchase made after a relaunch, without any product page in between, still carries them. Passing an empty customerID clears the saved one.
From 4.6.0, the SDK sends two events itself, you don’t need to add them:
We want you to track 3 events:
product_viewed
Parameters
Example
product_added_to_cart
Parameters
Example
checkout_completed
Parameters
Example
A/B testing
Requires iOS SDK 4.6.0 or later. Kleep can run an A/B holdout test on your app to measure what it brings: part of your shoppers see the Kleep CTA (group
test), the others don’t (group control). You start and stop the test from your Kleep dashboard, see A/B testing.
You have no code to add:
- Control group:
requestSizereturns.notSupported, so your app hides the CTA as it does for a product without size guide. - Test group: nothing changes.
- Same group on the web and in the apps: the group is computed from
customerID. Pass the same member ID as on your website, character for character, torequestSizeandloadView. Without it, the SDK uses an anonymous ID of the device: a shopper can then be in one group in the app and in the other on the web. - If anything fails, Kleep is shown: no network, no answer in time, no test running.
- When a change applies: the SDK reads the test status once per app session. After a start or a stop, each shopper gets the change at their next app launch, as soon as the status is refreshed (a product page opened in the first seconds of that launch may still use the previous one).
Log the group in your own analytics
requestSize does.
Test both groups
Force the group for the current app session, in your debug builds only. It has an effect only while a test is running:-kleep_ab control (or test) does the same without code.
Data collected by the SDK
The SDK sends data to Kleep over HTTPS: the shopper’s answers, to compute the size, and usage events. From 4.6.0, it also sends technical logs (errors, SDK version, device model) and the steps of the size guide with the recommended size and internal identifiers, without the answers given. While an A/B test runs, the customer identifier you pass (or an anonymous ID), the group and the product viewed are also sent to PostHog (EU), Kleep’s A/B testing processor. Nothing is sent to PostHog when no test runs for your account.

