The SDK on macOS

Mac apps, in SwiftUI or AppKit, use the SDK as iOS apps do: the same Swift package, which declares macOS from 0.8.0, with the same Swift API. The options, the configuration, the gate, the strings and the errors are the ones of the SDK on iOS; this page is what is different on a Mac. What the SDK does, what the API key allows and how the SDK behaves offline are on the SDK page. A Kotlin Multiplatform project with the macOS targets takes the SDK from Maven Central instead: Kotlin Multiplatform.

Install

The package is squiddy-cloud/squiddy-swift, at version 0.9.0, the same release as on the other platforms. In Xcode, File › Add Package Dependencies…, enter https://github.com/squiddy-cloud/squiddy-swift, choose Up to Next Major Version from 0.9.0, and add the library Squiddy to the Mac app's target. In a Package.swift:

platforms: [.macOS(.v12)],
dependencies: [
    .package(url: "https://github.com/squiddy-cloud/squiddy-swift", from: "0.9.0"),
],
targets: [
    .target(name: "MyMacApp", dependencies: [.product(name: "Squiddy", package: "squiddy-swift")]),
]

The XCFramework of the package has a macOS slice for Apple silicon and Intel Macs, so a Mac app builds for both architectures, as Xcode does by default.

MinimummacOS 12, Swift 5.9
app_type sent to Squiddydesktop, as a desktop application on the JVM: the blocks of a configuration that serve the desktop serve the Mac app, and the iOS app of the same appId stays ios
Bundle idthe main bundle's identifier; a program outside an app bundle, such as a command-line tool, has none and gives bundleId
FilesLibrary/Application Support/<bundle id>/squiddy, in the user's home or in the container of a sandboxed app, excluded from Time Machine. It is the directory a JVM build of the same app uses on a Mac, so the two find the same files
Sizeabout 12 MiB, for Apple silicon and Intel together

Mac Catalyst is not supported: the package has no slice for it, so an iPad app built for Mac Catalyst does not build. Build a Mac app, for the macOS destination, instead.

Initialize

Create one instance per app and Squiddy environment, when the app starts, and keep it. The application delegate is the place, also in a SwiftUI app (@NSApplicationDelegateAdaptor), since the push update needs it. Keep the key out of the repository as on iOS.

import AppKit
import Squiddy

final class AppDelegate: NSObject, NSApplicationDelegate {
    private(set) var squiddy: Squiddy?

    func applicationDidFinishLaunching(_ notification: Notification) {
        do {
            squiddy = try Squiddy.initialize(SquiddyOptions(
                host: "https://squiddy.example.com",
                apiKey: apiKey,
                appId: "my-app",
                appVersion: "2026.11.30",   // YYYY.MM.DD: Squiddy compares it as a number
                appMode: "release"))
        } catch {
            // SquiddyInitializationError: .invalidOptions(message:) names the option to fix
        }
    }
}

A command-line tool passes bundleId: "com.example.tool" in the options, since it has no bundle. The bundle id names the SDK's directory, so one that cannot be the name of a directory (a /, a space, ..) is refused with .invalidOptions: letters, digits, ., - and _, starting and ending with a letter or a digit.

When the SDK checks

A Mac app is in the foreground while some of it is visible on the screen. The SDK checks at every start, after serving the stored configuration; whenever a window of the app becomes visible again; and, if the API block of the configuration has a refreshInterval, at that interval while the app stays visible (the periodic check). It never checks while every window of the app is hidden, minimized in the Dock or covered, or the screen is locked. Being the active app is not needed: an app behind another one is in the foreground as long as one of its windows can be seen.

At start the app counts as in the foreground, before any window is on the screen, so an app without windows, such as a menu bar app, checks at start and then at the configuration's refreshInterval, as a desktop application on the JVM does. squiddy.refresh() checks at once, and the outcome arrives in config.

Language

The SDK asks Squiddy in the primary language of the user's first preferred language (it for it-IT), read again on NSCurrentLocaleDidChangeNotification and before every check; macOS gives an app the new preferred languages at its next launch. An app with its own language picker calls try squiddy.setLanguage("en"), and setLanguage(nil) goes back to the user's.

Push update

Push update reaches a Mac app as it reaches an iPhone: a data-only message of Firebase Cloud Messaging to the configuration's topic, which Apple Push Notification service delivers to the app, and the app passes to the SDK. What it takes is the iOS list (push update on iOS), with the Mac's names:

import FirebaseCore
import FirebaseMessaging

// In applicationDidFinishLaunching(_:), after initialize:
FirebaseApp.configure()
Messaging.messaging().delegate = self
NSApplication.shared.registerForRemoteNotifications()

// Hand the APNs token to Messaging yourself, as on iOS: it hands out its token, and so subscribes, only once it has it.
func application(_ application: NSApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    Messaging.messaging().apnsToken = deviceToken
}

// MessagingDelegate: Firebase hands a token at every launch and when it changes; subscribing again is harmless.
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
    guard let squiddy, fcmToken != nil else { return }
    messaging.subscribe(toTopic: squiddy.pushTopic)
}

func application(_ application: NSApplication, didReceiveRemoteNotification userInfo: [String: Any]) {
    if squiddy?.handlePush(userInfo) == true { return }   // Squiddy's: the SDK checks within pushRefreshJitter
    // the app's own notifications
}

handlePush(_:) returns true for Squiddy's notification and false for any other, which stays the app's. macOS delivers the notification to an app that is running: an app that is not running when Squiddy notifies does not hear of it, and reads the new configuration at its next start, which checks anyway. The topic, the random wait and how to tell that it works are the same as on iOS.