Skip to Content

iOS SDK

Using our iOS SDK makes it easy to integrate Shen.AI into a new or existing iOS app.

The best way to get started is to build one of our example apps:

The iOS integration uses the Objective-C API of the SDK, so it can be used directly in Swift and in Objective-C projects.

Installing the SDK package

The iOS SDK is distributed as the ShenaiSDK binary framework through Swift Package Manager and CocoaPods.

Swift Package Manager

In Xcode, open File > Add Package Dependencies… and add:

https://github.com/mxlaboratories/ShenaiSDK.git

Select version 3.1.1 or newer and add the ShenaiSDK product to your app target.

For a package manifest, add the dependency explicitly:

Package.swift
.package(url: "https://github.com/mxlaboratories/ShenaiSDK.git", from: "3.1.1")

CocoaPods

Add the pod to your app target:

Podfile
target "YourApp" do pod "ShenaiSDK", "3.1.1" end

Then run:

pod install

Custom frame input

If your app already owns the video pipeline, you can initialize the SDK with CameraMode.customFrames. In this mode the SDK will not open a camera and will wait for frames from your app.

let settings = InitializationSettings() settings.cameraMode = .customFrames let initResult = ShenaiSDK.initialize(API_KEY, userID: USER_ID, settings: settings)

Frames are submitted through the native iOS API as I420 data:

let metadata = FrameMetadata() metadata.timestampUs = Int64(DispatchTime.now().uptimeNanoseconds / 1_000) metadata.cameraFacingUser = true let accepted = ShenaiSDK.handleNextFrame(i420FrameData, width: width, height: height, metadata: metadata)

timestampUs is optional. When you provide it, it should be a monotonic capture timestamp in microseconds. If you leave it unset or negative, the SDK synthesizes monotonic submission-time timestamps. For best accuracy, provide source timestamps when available and prefer uniform sampling of at least 30 FPS. In CustomFrames mode, submit frames already rotated and resized as you want them processed; SDK-side rotation, frameWidth, and frameHeight are ignored. If your app restarts its own capture pipeline while staying in customFrames, call ShenaiSDK.setCameraMode(.customFrames) again before resuming handleNextFrame(...). Re-applying customFrames tells the SDK to start a new logical external-frame session.

handleNextFrame(...) is the native iOS frame-submission API for CustomFrames. If you use Flutter, React Native, Capacitor, or MAUI, configure CustomFrames in the framework layer and call the native Android/iOS frame-submission APIs from platform code; the framework bindings themselves do not accept raw frames.

Further steps

Please see permissions, initialization, configuration and video measurement for further steps.