For the complete documentation index, see llms.txt. This page is also available as Markdown.

Swift

Write and read records from Swift (iOS, macOS) with the Norbix Swift SDK.

The Swift SDK is a Swift package (source and releases: github.com/norbix-code/sdk-swift). It has two libraries: NorbixApi (your app's data: records, files, users) and NorbixHub (configuration). It needs Swift 5.9 and is built for Apple platforms: iOS 14, macOS 12, tvOS 14, watchOS 7 and visionOS 1 or newer.

This page was run on 2026-10-06 with version 1.8.0 and Swift 6.4 on macOS. All the code below is one file, Sources/Quickstart/main.swift of a command-line package: put the blocks one after the other.

Before you start

  • A project with a books collection — title (text, required), pages (number, required), in_stock (yes / no), genre. Create it in Cloud as in step 3 of the Quickstart.

  • A key and your project id in NORBIX_API_KEY and NORBIX_PROJECT_ID — see Install a Norbix SDK. The key needs a role that may write records, for example Data Editor.

Install

In Xcode: File → Add Package Dependencies…, enter https://github.com/norbix-code/sdk-swift, pick Up to Next Major from 1.8.0 and add the NorbixApi library to your target.

In a Package.swift:

// swift-tools-version: 5.9
import PackageDescription

let package = Package(
    name: "Quickstart",
    platforms: [.macOS(.v12)],
    dependencies: [
        .package(url: "https://github.com/norbix-code/sdk-swift.git", exact: "1.8.0"),
    ],
    targets: [
        .executableTarget(
            name: "Quickstart",
            dependencies: [.product(name: "NorbixApi", package: "sdk-swift")]
        ),
    ]
)

Create the client

import NorbixCore is needed for NorbixError in 1.8.0. To pass the values in code instead: try NorbixApiClient(projectId: "pr_…", apiKey: "nbsu_…").

Write a record

A record goes in as a JSON string in document. The answer is a dictionary with the new record's id.

Read records

find returns one page of records in list.items. Add filter, sort or projection to the request as in Search parameters.

Handle errors

A failed call throws a NorbixError with the gateway's code and message. Here the schema says pages is required:

Run it

The output (the collection already had The Hobbit):

Next steps

  • Every operation, with a tab per language: SDK reference.

  • The same calls from the terminal: CLI.

Last updated

Was this helpful?