Skip to content

System integration

Launch at login, open documents and links, receive shares, preview files in QuickLook and ship App Clips.

desktop.SetLaunchAtLogin(cx, on) registers the app with the platform’s login mechanism, and desktop.LaunchAtLogin(cx, done) reads it. An MSIX built by the current tool includes a disabled startup task automatically; enabling it respects the user’s Startup apps switch and administrator policy. Ordinary Windows and Linux installs keep their Run value and XDG autostart entry. macOS uses the bundled app’s native login service.

Flatpak requests the Background portal, which may ask for consent, without granting access to host configuration files. A subsequent read waits for the native reply. The portal has no read-only startup query: Flatpak reads return only the last confirmed reply in this run, false before one, and cannot detect a change outside the app or recover the setting on the next run.

An externally packaged Snap declares the autostart filename on its app:

apps:
app:
command: bin/app
autostart: app.desktop

NSGo writes that filename under $SNAP_USER_DATA/.config/autostart, which snapd launches through the app’s wrapper. desktop.LaunchedAtLogin(cx) distinguishes a login launch before the app builds, including an MSIX StartupTask activation.

file_types registers the documents an app opens: from the Finder, the Dock and Open With on macOS, from Explorer’s Open With through the Windows installer or the MSIX on Windows, through the desktop entry of the Debian, Arch, AppImage and Flatpak packages on Linux, and through Open In on iOS:

file_types:
- name: Flow File
extensions: [flow]
# id: dev.example.hello.flow # <id>.<first extension> by default; another's ID imports its type
# icon: assets/Flow.icns # macOS document icon; or a square PNG
# role: viewer # editor by default
# conforms: [public.json] # public.data by default
# mime: [application/json] # existing MIME types; otherwise inferred on Linux

The Windows installer adds the app to Open With without replacing the user’s default, and removes its registrations on upgrade and uninstall. Linux names the MIME types of common extensions from a fixed table, and gives an unknown extension of the app’s own type application/x-<type id> with a shared MIME-info definition. mime names existing types instead; an imported type whose extension the table lacks needs it. Running an AppImage registers nothing: a desktop integration tool installs its entry and definitions.

The app hears the files with desktop.OnOpenFiles, including a later Windows or Linux launch while it is running and iOS scene document opens. Files that launched the app wait for the first handler:

desktop.OnOpenFiles(cx, func(paths []string) { open(paths[0]) })

On Windows and Linux, both first and later launches take arguments naming existing regular files (including local file: URLs) before the first --, after NSGo removes its flags. The handler receives absolute paths. The default scan does not interpret subcommands or flags, so app -- editor scene.flow keeps both arguments out of file delivery.

For a CLI that needs to distinguish documents from subcommands or flag values, pass nsgo.LaunchFiles(parse) to nsgo.Run. The parser gets the arguments before --, without the executable or NSGo’s flags, with local file: URLs already turned into paths; on Linux it also sees any links among them. It returns filesystem paths, and NSGo resolves relative ones against the launching process’s working directory before a running instance gets them. Return nil to open no files for that launch, or pass nsgo.LaunchFiles(nil) to disable command-line file opens entirely, including Open With and choosing a recent file on Windows and Linux, which relaunch the app with the file’s path. Links still reach OnOpenLinks after --; on Windows a link launch never opens files or calls the parser.

On iOS, regular documents are imported into app-owned temporary files with their original names. File-provider reads are coordinated off the UI thread, and their security scopes end before the handler runs. Move an import into cx.DataDir() to keep it; edits affect the copy. iOS uses the app’s document icon; icon applies on macOS. App Clips and tvOS packages register no document types. File opens stay separate from OnOpenLinks.

desktop.AddRecentFile(cx, path) records a document the user opened: in the Dock menu and File › Open Recent on macOS, the Jump List’s Recent category on Windows, and the desktop’s recently used files on Linux. A choice reaches the same handler. desktop.ClearRecentFiles forgets the app’s registrations, keeping other apps’ history of shared files on Linux; Linux also respects GTK’s history setting.

desktop.SetDockMenu(cx, items) sets actions on the app’s icon: macOS’s Dock menu, Windows’ Jump List tasks and the quicklist on Linux’s Ubuntu dock, Plasma and Dash to Dock where quicklists are supported. Linux needs an installed desktop entry matching the app’s id, and keeps submenus, separators, checked and disabled items. The menu belongs to the scope that set it, and the last setter across the app’s windows replaces it.

url_schemes gives the app links of its own, such as myapp://settings, which open it from a browser, another app, open, start or xdg-open. The macOS, iOS and Android apps register them, as do the Windows installer and MSIX package and the Linux desktop entry, which the Debian, Arch, AppImage and Flatpak packages carry. Uninstalling removes them.

url_schemes: [myapp]
# app_links: [links.example.com] # HTTPS hosts for the full app

The app hears them with desktop.OnOpenLinks, also while it runs: on Windows and Linux a second launch hands its link to the running app and exits. A link that launched the app waits for the first handler. Anyone can write such a link, and on Windows and Linux the handler hears any URL the app is started with, so check the scheme and ask the user before a link changes anything:

desktop.OnOpenLinks(cx, func(links []string) { show(links[0]) })

On iOS and Android, mobile.OnOpenLinks hears links at launch and while the app runs. Open one with xcrun simctl openurl booted myapp://settings on the iOS simulator or adb shell am start -a android.intent.action.VIEW -d myapp://settings on Android. app.OpenLinks("myapp://settings") delivers one in a test.

For iOS universal links, declare explicit HTTPS hosts with app_links: [links.example.com]. Each host is a DNS name without a scheme, path, port, IP address or wildcard; names are lowercased and duplicates are rejected. The tool writes applinks:<host> to the full app’s Associated Domains entitlement, including Xcode-managed signing; an IPA profile must authorize it. App Clips retain the separate appclips: claims from app_clip.domains.

Each host must serve an apple-app-site-association file that names the full app at https://<host>/.well-known/apple-app-site-association; package metadata alone cannot authorize a universal link. Apple’s association requirements describe the server setup. Ad hoc simulator signatures omit restricted developer entitlements, so a delegate test does not establish server association.

On iOS, mobile.OpenedURL(cx) tracks the most recent App Clip invocation, universal link or custom scheme URL, including the initial value before the root mounts. Custom scheme delivery still reaches mobile.OnOpenLinks; the invocation value is current when that handler runs. File opens stay in OnOpenFiles and do not replace the invocation URL. Android/Web invocation support is tracked separately in #1475.

app_links names explicit HTTPS hosts whose links open the full Android app:

app_links: [example.com, shop.example.com]

The APK and App Bundle declare a browsable ACTION_VIEW filter with autoVerify for each host. Use DNS hosts without a scheme, path, port, wildcard or IP address. Serve https://<host>/.well-known/assetlinks.json with the app’s package ID and signing certificate fingerprint; Android verifies that association before routing links to the app. The tool does not publish association files; Android’s verification guide describes their setup. An embedded Android host declares its own intent filters and forwards accepted links to its NsgoView.

mobile.OpenedURL(cx) reads the accepted invocation before the first root render and changes when another link opens the running app. mobile.OnOpenLinks still hears each accepted link. A whole-page web app reads its current page address through mobile.OpenedURL, including browser history and hash changes; an app mounted inside another page reads no containing-page address. Use cx.AppURL when the app also writes its address.

Choose the MIME types the app handles from the Android share sheet:

android:
share_types: [text/plain, 'image/*', application/pdf]

APK and App Bundle builds register those types for both single and multiple items. Register mobile.OnShared to receive each share.

For a web app with path-based addresses, set web.base to its deployment directory (/ or /my-app/) and configure your production server to serve index.html for application routes. The development server already provides that fallback for HTML navigation requests. Assets remain relative to that fixed HTML base when a deep link is reloaded. See Application addresses.

Declare the Uniform Type Identifiers the share extension accepts, with URL and text types before broader file types:

apple:
share_types: [public.url, public.plain-text, public.image, com.adobe.pdf]
# share_open_app: true # open the app once a share is saved; needs url_schemes
# app_group: group.com.example.app # defaults to group.<id>
sign:
# share_profile: assets/Share.mobileprovision

build and dev package a Go share extension, <id>.share, with the app. Xcode signs it and registers its App Group for device runs. For an IPA, enable the same App Group for <id> and <id>.share; sign.profile and sign.share_profile must grant it. App Clips, tvOS and watchOS have no share extension.

The extension shows the app’s icon and name while it copies up to 128 items and 512 MiB of files into the App Group, then says the share was saved and to open the app, or why it failed, and closes the share sheet. Its words are github.com/nsgo-dev/nsgo/mobile/locales’ shareSaved, shareFailed, shareTooLarge, shareDone and shareCancel, in the language of the app’s catalogs that suits the user’s; the app’s catalogs can supply them under that import path, with {app} for the app’s name. mobile.OnShared receives those batches while the app is active or when the user next opens it; they survive the extension and app exiting before delivery. iOS provides no supported API for a Share extension to foreground or launch its containing app. This handoff therefore does not automatically open the app.

apple.share_open_app: true opens it anyway: once the share is saved, the extension opens <scheme>://nsgo-share, with the first of url_schemes, in place of its confirmation, which it shows only if the app does not open. The app then receives the share through mobile.OnShared as it becomes active, and that link through mobile.OnOpenLinks and mobile.OpenedURL, where the host nsgo-share tells it from the app’s own links. The extension reaches UIApplication’s openURL:options:completionHandler: through its responder chain, which is outside the APIs Apple documents for extensions: App Review may reject the app for it, and a future iOS may stop it working, when the confirmation shows again. It is off by default.

On macOS, quicklook embeds a QuickLook Preview Extension (Contents/PlugIns/QuickLookPreview.appex) so Finder previews the app’s documents with an NSGo view, and quicklook_thumbnail a Thumbnail Extension (Contents/PlugIns/QuickLookThumbnail.appex) so Finder’s icons, Cover Flow and Dock stacks show them drawn by NSGo; an app may have either or both:

quicklook:
main: ./cmd/quicklook # Go main package calling nsgo.RunQuickLook
# id: dev.example.app.quicklook # <id>.quicklook by default
# types: [dev.example.app.doc] # defaults to all UTIs declared in file_types
quicklook_thumbnail:
main: ./cmd/thumbnail # Go main package calling nsgo.RunQuickLookThumbnail
# id: dev.example.app.thumbnail # <id>.thumbnail by default
# types: [dev.example.app.doc] # defaults to all UTIs declared in file_types

The preview’s entry package calls nsgo.RunQuickLook(Preview) (accepting nsgo.WindowSize for the preview’s preferred content size, nsgo.Fonts, nsgo.Appearance, nsgo.Component, nsgo.DataDir and nsgo.OnError). Preview receives the selected file’s path directly, and "path" and "url" are also available in cx.HostParams(). The thumbnail’s entry package calls nsgo.RunQuickLookThumbnail(Thumbnail) (accepting nsgo.Fonts, nsgo.Appearance, nsgo.Component, nsgo.DataDir and nsgo.OnError). Thumbnail receives the file’s path and the largest size in points Finder asks for, which its root fills; "path", "url", "width", "height" and "scale" are also in cx.HostParams(). Each thumbnail renders in a window that never shows and is drawn off the screen at the request’s scale, without what only the GPU draws: GPU and shader views, video, web pages, backdrop blur and glass. Finder asks for many at once; four render together, and one not drawn within ten seconds, or whose view draws nothing, fails, so Finder keeps the file’s icon.

macOS runs both extensions inside App Sandbox with read access granted only to the requested file URL. build signs each .appex with com.apple.security.app-sandbox before signing the app — ad hoc for local builds and dev (which registers it with pluginkit -a), with sign.identity and hardened runtime/timestamp when notarizing, and for provisioned Mac App Store builds with sign.quicklook_profile (-quicklook-profile) for the preview and sign.quicklook_thumbnail_profile (-quicklook-thumbnail-profile) for the thumbnail, from the same team — and macos_universal joins their binaries with lipo.

An App Clip is a small part of an iOS app that runs from a link, a code or an NFC tag without installing the app. app_clip builds one into the iOS package, from a main package of its own so it links only what it shows:

app_clip:
main: ./clip # the clip's main package, the app's own by default
domains: [example.com] # whose links open it
# name: Hello Clip # "<name> Clip" by default
# id: dev.example.hello.Clip # <id>.Clip by default
# minimum: "17.0" # 16.0 by default; 17.0 allows 100 MB when only links open it
# notifications: true # ask for notifications for a day
# location: true # let the clip confirm where it was opened

The clip reads the link that opened it with mobile.OpenedURL, which changes as another link opens it again, and mobile.IsAppClip says whether the code runs as one. The system downloads a clip of up to 15 MB, or 100 MB from iOS 17 when only links open it, and build refuses a larger one; a clip linking ui takes about 11 MB. dev -target ios_simulator -clip https://example.com/order?table=12 runs the clip alone in the simulator, opened from that link; -target ios runs it on an iPhone and prints the link’s QR code: add the link in Settings > Developer > Local Experiences, then scan it with the camera. Use -release if development symbols push the clip over the QR size limit. Apple signs App Clips only for teams of the Apple Developer Program, not personal teams.

dev -target ios and build -run -target ios also keep the clip inside the full app: Xcode signs it as a separate target and embeds it before signing the app. Automatic signing needs an authenticated paid-team account in Xcode, with provisioning for both app and clip. For the App Store, enable App Clips for <id>, sign the clip with sign.clip_profile, and serve the apple-app-site-association file of the domains. The repository’s examples/appclip is a café whose clip orders at a table.

To hand an order or other local data to the full app, set an explicit group alongside app_clip:

apple:
app_group: group.dev.example.hello

The clip and full app then share cx.DataDir() and cx.Storage() in the group’s container. Files under the data directory and key-value entries the clip writes are available when the full app starts; cx.LogsDir() follows that directory, while each bundle keeps its own cache. Xcode signing claims the group for both targets; when using profiles, enable the same group for both App IDs and grant it in sign.profile and sign.clip_profile. A missing grant refuses signing, and an inaccessible group stops startup. A host’s explicit data directory still takes precedence.

Without apple.app_group, each bundle keeps its own sandbox storage. Enabling the setting does not migrate data previously stored in those sandboxes, and widget-only apps keep their existing storage location. Keep shared secrets in the keychain rather than plain storage. The café example persists its clip’s order and displays it in the full app.

From an explicit user action inside the clip, call mobile.ShowAppClipOverlay(cx, mobile.AppClipOverlayBottom) to ask StoreKit to recommend its corresponding full app. AppClipOverlayBottomRaised leaves room for a bottom bar. The returned function dismisses that request; scope cleanup also dismisses it, and an older request cannot dismiss a newer one. Calls outside a native iOS App Clip do nothing. The App Store decides whether it can load and display the recommendation, so the call reports neither a displayed offer nor an installation. Keep the clip’s task usable without installing the full app. Apple’s overlay guidance

build and dev compile the extension that draws the app’s widgets and Live Activities into the macOS and iOS packages with Xcode’s Swift compiler, with no separate step. On iOS the app and its widgets share an app group: -run on an iPhone has Xcode sign both and register the group; for an IPA, enable it for both <id> and <id>.widgets, and sign the extension with sign.widgets_profile. Android standalone APKs and AABs include App Widget providers and resources from widgets; the prebuilt Java runtime draws their timelines with no SDK or Java compiler needed by app builds. Android 16 shows Live Activities as Live Updates, which need no extension. Widgets and Live Activities cover their configuration and API.