PrismSDK v1.0.0 ← Back to versions

PrismSDK iOS

Camera-based body scanning SDK — pose detection, measurements, and health analytics.

Module Architecture

// Dependency direction: PrismUI -> PrismKit -> PrismLink

PrismUI      SwiftUI views, theming, audio guidance
  PrismSessionView            SwiftUI entry point
  PrismSessionViewController  UIKit entry point
  PrismThemeConfiguration     Colors, fonts, icons

PrismKit     Camera, pose detection, state machine, recording
  CaptureSession              Main orchestrator
  CaptureSessionState         Flow state enum
  PrismStateManager           Protocol for step managers

PrismLink    REST API client, models
  ScanClient                  Scan CRUD, measurements, health
  UserClient                  User management
  ApiClient                   Base HTTP client

PrismSessionView

The complete capture session flow as a SwiftUI view.

public struct PrismSessionView: View

Provides the entire capture experience — volume check, device leveling, face guidance, body positioning, A-pose validation, recording, and completion — as a single SwiftUI view with voice guidance and sound effects.

Initializer

public init(
    receivedArchive: @escaping (URL) -> Void,
    onStatus: @escaping (CaptureSessionState) -> Void,
    onDismiss: @escaping () -> Void
)
ParameterTypeDescription
receivedArchive(URL) -> VoidCalled with the file URL of the recording zip archive when capture completes.
onStatus(CaptureSessionState) -> VoidCalled on each capture state change. Useful for analytics.
onDismiss() -> VoidCalled when the session view is dismissed.

Environment Values

KeyTypeDescription
\.enableFaceGuidanceBoolEnables face guidance step. Default: false.
\.useScanReviewBoolShows scan review screen before completing. Default: false.
\.prismThemeConfigurationPrismThemeConfigurationTheme for colors, fonts, and icons.

Usage

PrismSessionView(
    receivedArchive: { url in
        print("Archive: \(url)")
    },
    onStatus: { _ in },
    onDismiss: {}
)
.environment(\.enableFaceGuidance, true)
.applyTheme(.default)

PrismSessionViewController

UIKit wrapper for the capture session flow.

public class PrismSessionViewController: UIViewController

Initializer

public init(
    theme: PrismThemeConfiguration = .default,
    delegate: PrismSessionViewControllerDelegate? = nil
)
ParameterTypeDescription
themePrismThemeConfigurationTheme configuration. Defaults to .default.
delegatePrismSessionViewControllerDelegate?Delegate for capture callbacks.

Usage

let vc = PrismSessionViewController(
    theme: .default,
    delegate: self
)
vc.modalPresentationStyle = .fullScreen
present(vc, animated: true)

PrismSessionViewControllerDelegate

Delegate protocol for receiving capture callbacks in UIKit.

public protocol PrismSessionViewControllerDelegate: AnyObject

Required Methods

MethodDescription
prismSession(_:didRecieveArchive:)Called when capture completes with the archive file URL.
prismSession(_:didChangeStatus:)Called on each state change. Use for analytics.
prismSession(willDismiss:)Called before dismissal. You must call controller.dismiss(animated:).

Signatures

func prismSession(
    _ controller: PrismSessionViewController,
    didRecieveArchive archive: URL
)

func prismSession(
    _ controller: PrismSessionViewController,
    didChangeStatus status: CaptureSessionState
)

func prismSession(
    willDismiss controller: PrismSessionViewController
)

PrismThemeConfiguration

Comprehensive theming for colors, fonts, icons, and component styling.

public struct PrismThemeConfiguration

Static Properties

PropertyTypeDescription
.currentPrismThemeConfigurationCurrently applied theme singleton.
.defaultPrismThemeConfigurationDefault Prism theme.

Color Properties

PropertyTypeDescription
primaryColorColorPrimary brand color
secondaryColorColorSecondary brand color
tertiaryColorColorTertiary accent color
successColorColorSuccess states
errorColorColorError states
backgroundColorColorPrimary background
secondaryBackgroundColorColorSecondary background
overlayColorColorOverlay/dimming
borderColorColorBorder color
disabledColorColorDisabled states

Text & Font Properties

PropertyTypeDescription
titleTextColorColorTitle text color
textColorColorGeneral text color
buttonTextColorColorButton text color
largeTitleFontFontLarge title font
titleFontFontTitle font
secondaryTitleFontFontSecondary title font
bodyFontFontBody text font

Component Properties

PropertyTypeDescription
primaryButtonCornerRadiusCGFloatPrimary button corners (default: 12)
smallButtonCornerRadiusCGFloatSmall button corners (default: 12)
cardCornerRadiusCGFloatCard/alert corners (default: 12)
sheetCornerRadiusCGFloatBottom sheet corners (default: 12)

View Modifiers

// Apply full theme
.applyTheme(myTheme)

// Apply individual properties
.theme(\.primaryColor, .blue)
.theme(\.bodyFont, .custom("Avenir", size: 16))

CaptureSession

Main orchestrator for the body scan capture flow.

public class CaptureSession: ObservableObject

Coordinates the entire capture pipeline: camera management, pose detection, device leveling, and recording. Publishes reactive state updates via Combine @Published properties.

Type Properties

PropertyTypeDescription
isSupportedBoolWhether the device supports body scanning (requires TrueDepth camera).

Published Properties

PropertyTypeDescription
stateCaptureSessionStateCurrent capture flow state.
states[CaptureSessionState]Remaining states in the flow.
permissionsCameraPermissionStatusCamera permission status.
currentRecordingPrismRecording?Completed recording data.
cameraBufferCameraBuffer?Current camera frame buffer.
poses[Pose]?Detected body poses.
annotatedFrameCGImage?Frame with pose skeleton overlay.
levelStatePrismStateDevice leveling state.
levelResultMotionDetector.LevelCurrent device level.
verticalRotationDoubleDevice vertical rotation angle.
positioningStatePrismStateBody positioning state.
positioningResultDetectionFeedback?Body positioning feedback.
posingStatePrismStateA-pose validation state.
posingResultDetectionFeedback?Pose validation feedback.
recordingStatePrismStateRecording state.
recordingCountDownIntCountdown timer value.
recordingUrlURL?Output recording file path.
faceGuidanceStateFacePositionManagerStateFace guidance state.

Instance Properties

PropertyTypeDescription
configurationCaptureSessionConfigurationSession configuration.
faceGuidanceEnabledBoolWhether face guidance is enabled.

Methods

MethodDescription
start() async throwsInitialize and start the capture session.
stop() async throws -> URLFinalize recording and return archive path.
cancel() async throwsCancel the entire session.
checkAndContinue(from:start:)Check if current state is complete and advance.
continue(from:shouldStart:)Advance to the next state.
startStep()Begin processing the current step.

PrismCaptureSession

SwiftUI ObservableObject wrapper around CaptureSession.

public class PrismCaptureSession: ObservableObject

Properties

PropertyTypeDescription
sessionCaptureSessionThe underlying capture session.

Initializer

public init(configuration: CaptureSessionConfiguration = .init())

CaptureSessionConfiguration

Configuration options for a capture session.

public struct CaptureSessionConfiguration

Properties

PropertyTypeDescription
poseThemePoseThemeSkeleton visualization theme.
recordingModeRecordingMode.frames or .video.

Initializer

public init(poseTheme: PoseTheme = .default, recordingMode: RecordingMode = .video)

CaptureSessionState

All possible capture session states.

@frozen public enum CaptureSessionState: Identifiable, Equatable, Hashable

Cases

CaseDescription
.idleInitial/waiting state.
.volumeVolume setup step.
.faceGuidanceFace capture guidance (optional).
.levelingDevice leveling step.
.positioningBody positioning step.
.posingA-pose verification step.
.recordingActive recording.
.processingArchive finalization.
.finishedSession complete.
.failed(Error)Error state.

PrismState

State of an individual step manager.

@frozen public enum PrismState: Equatable, Hashable, Identifiable, CaseIterable

Cases

CaseDescription
.idleNot running.
.runningActively processing.
.finishedProcessing complete.

PrismStateManager

Protocol for step managers in the capture state machine.

public protocol PrismStateManager

Required Properties

PropertyTypeDescription
waitTimeTimeIntervalHold time before auto-advancing.
statePrismStateCurrent manager state.

Required Methods

MethodDescription
start()Begin processing.
stop()Halt and mark finished.

CaptureError

Errors during the capture session.

@frozen public enum CaptureError: Error

Cases

CaseDescription
.unsupportedDeviceNo TrueDepth camera.
.invalidDocumentDirectoryCannot access documents directory.
.invalidRecordingRecording state error.
.videoURLEmptyVideo file not created.

CameraPermissionStatus

Camera authorization status.

@frozen public enum CameraPermissionStatus: Identifiable, CaseIterable

Cases

CaseDescription
.notDeterminedNot yet requested.
.restrictedRestricted by parental controls.
.deniedUser denied access.
.authorizedUser granted access.

ApiClient

Base HTTP client for the Prism API.

public final class ApiClient: ObservableObject, Sendable

Handles HTTP communication with the Prism backend. Loads configuration from PrismSDK-Info.plist by default.

Initializer

public init(
    baseURL: URL? = nil,
    clientCredentials: ApiClientBearerToken? = nil
)
ParameterTypeDescription
baseURLURL?API base URL. Defaults to plist value.
clientCredentialsString?Bearer token. Defaults to plist value.

ScanClient

API client for scan operations.

public struct ScanClient: Sendable

Initializer

public init(client: ApiClient)

Scan Methods

MethodDescription
createScan(_:) async throws -> ScanCreate a new scan record.
getScan(forScan:unitSystem:) async throws -> ScanFetch a scan by ID.
getScans(forUser:limit:cursor:order:unitSystem:) async throws -> Paginated<Scan>Fetch paginated scans.
deleteScan(_:) async throws -> ScanDelete a scan.

Upload Methods

MethodDescription
uploadUrl(forScan:) async throws -> UploadUrlGet presigned upload URL.
assetUrls(forScan:) async throws -> AssetUrlsFetch all asset URLs.
assetUrl(forScan:option:) async throws -> StringFetch a specific asset URL.

Results Methods

MethodDescription
measurements(forScan:unitSystem:) async throws -> MeasurementsFetch body measurements.
getBodyFat(forScan:unitSystem:) async throws -> BodyfatFetch body fat data.
updateBodyFatMethod(forScan:_:unitSystem:) async throws -> BodyfatUpdate body fat method.
getHealthReport(forScan:unitSystem:) async throws -> HealthReportFetch health report.
createBodyShapePrediction(_:unitSystem:) async throws -> BodyShapePredictionCreate body shape prediction.
getBodyShapePrediction(forBodyShapePrediction:unitSystem:) async throws -> BodyShapePredictionFetch prediction status.

UserClient

API client for user management.

public struct UserClient: Sendable

Initializer

public init(client: ApiClient)

Methods

MethodDescription
create(user:) async throws -> UserCreate or upsert a user.
update(user:) async throws -> UserUpdate an existing user.
fetchUser(for:unitSystem:) async throws -> UserFetch user by token.

Scan

Scan data models.

Scan

public struct Scan: Codable, Sendable
PropertyTypeDescription
idStringUnique scan identifier.
userIdStringAssociated user ID.
userTokenStringUser token.
statusStatusProcessing status.
weightWeightUser weight at scan time.
heightHeightUser height at scan time.
measurementsMeasurements?Body measurements (when ready).
bodyfatBodyfat?Body fat data (when ready).
scanAssetsScanAsset?Scan assets.
createdAtDateCreation timestamp.
updatedAtDateUpdate timestamp.

NewScan

public struct NewScan: Codable, Sendable
PropertyTypeDescription
deviceConfigNameStringDevice configuration name.
userTokenStringUser token.
bodyfatMethodBodyfatMethod?Body fat calculation method.
assetConfigIdAssetConfigId?Asset configuration ID.

UnitSystem

public enum UnitSystem: String, Codable
CaseDescription
.imperialInches, pounds.
.metricMeters, kilograms.

Measurements

Body measurement results from a completed scan.

public struct Measurements: Codable, Sendable

All properties are Double values in the requested unit system.

PropertyBody Region
neckFitNeck circumference
shoulderFitShoulder width
chestFitChest circumference
waistFitWaist circumference
hipsFitHips circumference
thighLeftFit / thighRightFitMid-thigh
calfLeftFit / calfRightFitCalf
midArmLeftFit / midArmRightFitBicep
forearmLeftFit / forearmRightFitForearm
wristLeftFit / wristRightFitWrist
waistToHipRatioWaist-to-hip ratio

HealthReport

Comprehensive health analysis from a scan.

public struct HealthReport: Codable, Identifiable
PropertyTypeDescription
scanScanInfoScan metadata.
userUserInfoUser information.
bodyFatPercentageReportBodyFatPercentageReportBody fat % with health label.
leanMassReportLeanMassReportLean mass analysis.
fatMassReportFatMassReportFat mass analysis.
waistCircumferenceReportWaistCircumferenceReportWaist health analysis.
waistToHipRatioReportWaistToHipRatioReportWHR analysis.
waistToHeightRatioReportWaistToHeightRatioReportWHtR analysis.
metabolismReportMetabolismReportBMR, TDEE, caloric recommendations.
metabolicAgeReportMetabolicAgeReport?Estimated metabolic age.

User

User data models.

User

public struct User: Codable, Sendable
PropertyTypeDescription
idStringInternal user ID.
tokenStringYour unique identifier.
emailString?User email.
sexSexUser sex.
regionStringUser region.
birthDateDateBirth date.
weightWeightUser weight.
heightHeightUser height.
researchConsentBoolResearch consent flag.

NewUser

public struct NewUser: Codable, Sendable

All User fields plus termsOfService: TermsOfService.

ExistingUser

public struct ExistingUser: Codable, Sendable

Update payload. Only token is required; all other fields optional.

Shared Types

Common types used across the SDK.

Sex

public enum Sex: String, Codable, CaseIterable

Cases: .male, .female, .neutral

Height

public struct Height: Codable, Sendable
PropertyTypeDescription
valueDoubleHeight value.
unitHeight.Unit.inches or .meters.

Weight

public struct Weight: Codable, Sendable
PropertyTypeDescription
valueDoubleWeight value.
unitWeight.Unit.pounds or .kilograms.

BodyfatMethod

public enum BodyfatMethod: String, Codable, CaseIterable

Cases: .adam, .army, .army_athlete, .coco, .coco2, .coco_legacy, .coco_bri, .extended_navy_thinboost, .tina_fit

PrismError

public struct PrismError: Codable, Sendable
PropertyTypeDescription
statusCodeIntHTTP status code.
messages[String]Error messages.
errorString?Underlying error.

Version

public struct Version
PropertyTypeDescription
.currentVersionCurrent SDK version (static).
major / minor / patchUIntVersion components.
buildUIntBuild number.
semanticVersionNumberString"X.Y.Z" format.