Skip to content
imaged
Docs / Setup / Objective-C

Objective-C setup.

The same xcframework Swift uses, called from .m or .mm.

Prerequisites
Xcode 15.0 or later
Platforms macOS Sonoma+ arm64, iOS 15+
Bridging Pure ObjC works in .m; mixed C++ requires .mm
License token JWT issued from /dashboard
  1. 01

    Download the framework

    Same imaged.xcframework as the Swift setup. ObjC headers ship inside the framework under Headers/sdk_objc.h.

    bash
    unzip imaged.xcframework-ios.zip
  2. 02

    Embed in Xcode

    Drag imaged.xcframework into the target. In General > Frameworks, Libraries, and Embedded Content, set it to Embed & Sign. The umbrella header pulls in the ObjC surface; you do not need a Swift bridging header.

  3. 03

    Hello world

    Import the umbrella, allocate AISDK, set the license, check it, log the version. The Swift names you see in the iOS example map to ObjC selectors like -getOptions, -familyDetect:image:.

    objc
    #import <imaged/imaged.h>
    
    int main(int argc, const char *argv[]) {
        @autoreleasepool {
            AISDK *ai = [[AISDK alloc] init];
            AIConfigurationOptions *cfg = [ai getOptions];
    
            [cfg setOptionForKey:@"license.token"
                     stringValue:@"your-license-token"];
            [cfg setOptionForKey:@"license.audience"
                     stringValue:@"cameras.acme.com"];
    
            AIConfigurationOptionsStatus status = [cfg checkLicense];
            if (status != AIConfigurationOptionsStatusSuccess || ![ai isLicensed]) {
                NSLog(@"license check failed, status %ld", (long)status);
                return 1;
            }
    
            NSLog(@"imaged %@", [ai getVersion]);
        }
        return 0;
    }
  4. 04

    Run a family

    familyDetect:image: returns AIResponseObject with a typed objects array. Same call as Swift, just the ObjC selector form.

    objc
    AIImage *img = [[AIImage alloc] init];
    [img loadFrom:@"bus.jpg"];
    
    [cfg setOptionForKey:@"yolo.model"
             stringValue:[[NSBundle mainBundle] pathForResource:@"yolo26x"
                                                         ofType:@"onnx"]];
    AIResponseObject *response = [ai familyDetect:@"yolo" image:img];
    for (AIDetectedObject *obj in response.objects) {
        NSLog(@"%@ %.2f", obj.label, obj.score);
    }
  5. 05

    Where to go next

    The Swift example in the examples repo is the closest reference; ObjC selectors mirror the Swift ones one-to-one through the NS_SWIFT_NAME annotations in sdk_objc.h.