Nosmai  Effects Nosmai  Moderation Nosmai Try-ons coming soon
Docs menu iOS
Tutorial

iOS quickstart

Initialize Nosmai Effects, attach its processed camera preview, start capture, and apply a beauty effect on iOS.

Platform iOS SDK version 3.0.4 Updated Aug 22, 2026 Time 15 min

Prerequisites

1. Confirm camera permission text

<key>NSCameraUsageDescription</key>
<string>This app uses the camera for real-time filters and effects.</string>

The system terminates an app that requests camera access without this key.

2. Request camera access

Request permission before presenting the processed preview:

[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo
                         completionHandler:^(BOOL granted) {
    dispatch_async(dispatch_get_main_queue(), ^{
        if (granted) {
            [self initializeNosmai];
        }
    });
}];

Skip the prompt when authorization is already granted, and show an app-owned settings message when access was denied.

3. Initialize Nosmai once

Initialize from the application owner and continue from the successful completion:

[[NosmaiCore shared]
    initializeWithAPIKey:@"NOSMAI-YOUR-IOS-LICENSE-KEY"
              completion:^(BOOL success, NSError *error) {
    if (!success) {
        NSLog(@"Nosmai initialization failed: %@", error.localizedDescription);
        return;
    }

    [self startNosmaiCamera];
}];

Replace the documentation key with application-owned configuration.

4. Attach and start the preview

Attach the SDK camera to an existing UIView owned by the camera controller:

NosmaiCore *core = [NosmaiCore shared];
NosmaiCameraConfig *config = [[NosmaiCameraConfig alloc] init];
config.position = NosmaiCameraPositionFront;
config.sessionPreset = AVCaptureSessionPresetHigh;
config.frameRate = 30;

[core.camera updateConfiguration:config];
[core.camera attachToView:self.previewView];
[core.camera startCapture];
[core.effects applySkinSmoothing:0.4f];

Keep camera attachment and preview updates on the main thread.

5. Stop capture when leaving

Release the preview when its screen is no longer visible:

[[NosmaiCore shared].camera stopCapture];
[[NosmaiCore shared].camera detachFromView];

Call cleanup only when the application no longer needs the shared SDK state. Build and run on a physical device, not iOS Simulator.

Verify it worked

You should see the front-camera preview, the status Camera ready with skin smoothing, and a visible smoothing change at level 0.4. Leave the screen and confirm the iOS camera indicator turns off. Return and confirm capture restarts without a second initialization.

Common errors

ErrorCauseFix
SDK initialization failedNative initialization or licence setup did not completeInspect the accompanying NSError, key, bundle ID, and network access
SDK not initializedCamera or effects API was accessed before completionMove camera setup inside the successful initialization completion
Camera preview not availableNo preview view is attachedCall attachToView: before startCapture
Camera not activeCapture-dependent operation ran before the camera startedConfirm permission and check the Boolean result from startCapture
building for iOS Simulator, but linking in object file built for iOSThe framework has no simulator sliceSelect a physical arm64 iOS device

Next steps

References

Was this page helpful?

Your response helps us prioritize documentation improvements.

Nosmai

An AR and AI company. Founded on the idea that the next decade of software will be visual, and that the tools for it should be within reach of anyone building.

Newsletter

Product updates and release notes. No spam.

© 2026 nosmai, inc · all rights reserved