Skip to content
imaged

Objective-C setup

Apple platforms through the Slab C interface

Objective-C uses Slab's C interface directly, through the Slab framework in Slab.xcframework (iPhone/iPad, Simulator and Mac, arm64). There is no separate wrapper: every function in the C reference is callable as is.

Example: Classify.m.

Add to an app

  • Drag Slab.xcframework into the Xcode project and set it to Embed & Sign, or add the ios folder as a local Swift package and link its Slab framework.
  • Import it with @import Slab; (modules enabled, the default) or #import <Slab/Slab.h>.

Bridging notes

  • Handles are uint8_t *. Free each with its _free function; ARC does not manage them. Wrap them in your own classes with dealloc if you like.
  • Strings in: pass UTF-8 bytes and their length, e.g. NSData *d = [s dataUsingEncoding:NSUTF8StringEncoding] then (uint8_t *)d.bytes, d.length.
  • Strings out: build an NSString from the _ptr / _len pair with initWithBytes:length:encoding:. Copy before the next call on that object.
  • Camera frames: lock a 32BGRA CVPixelBuffer and pass its base address, bytes per row, width and height to slab_frame_set_pixels with SLAB_PIXEL_BGRA8 and copy = 1.
  • Threads: one operation at a time per session; run sessions on a background queue. slab_session_cancel works from any thread.

Swift apps can use the Swift API instead.

Requirements and license

Use iOS / iPadOS 18 or later, or macOS 15 or later on Apple silicon. The simulator slice is arm64. List the bundle ID of every app or extension that loads Slab in the license. New app-ID licenses require neither an Apple App ID prefix nor a Keychain group. See Licenses & renewals.

License details

Slab 0.2.0 exposes the attached license on Config and Session. Use it to display expiry and send renewal reminders to whoever maintains the license.

Config member Value
slab_config_runtime_license_seconds_left(cfg) Seconds remaining
slab_config_runtime_license_expires_at(cfg) Expiry, Unix seconds
slab_config_runtime_license_not_before(cfg) Start of validity, Unix seconds
slab_config_runtime_license_issued_at(cfg) Issue time, Unix seconds
slab_config_runtime_license_kind(cfg) License kind
slab_config_runtime_license_features(cfg) Enabled feature flags
slab_config_runtime_license_id_ptr(cfg) / _id_len(cfg) License ID

Seconds remaining becomes negative after expiry and is 0 without a license. Kind values are 0 none, 1 production, 2 trial and 3 pilot. Feature bits are 1 core, 2 graph models, 4 generative, 8 GPU, 16 NPU and 32 protected models.

The session equivalents start with slab_session_runtime_license_ and take a session handle.

For protected models, generate a license with your model key in the console. Attach that license before opening the pack. See licensing for model protection and renewals.