Index of every page on this site: llms.txt
All skills
daveebbelaar avatar

/build-and-verify

@22dc792
by Dave Ebbelaardaveebbelaar/bama1.9k stars
238
Run it yourself

Build a SwiftUI macOS app from the command line, install it, and check light and dark window snapshots of every page before calling a change done. Use after any UI code change, when a build fails, or when the user asks to run, screenshot, or check the app.

Use this Skill: https://skilld.dev/gh/daveebbelaar/bama/build-and-verify

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

existing-app.md

≈1.3k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Existing apps

The ship and code skills assume an app made from the new-mac-app template: SwiftPM, build.sh, APP_SNAPSHOT, APP_STORE, Swift 6 with main-actor default isolation. An older app, or one built with Xcode or XcodeGen, has none of these. Map each piece first, then follow the skills.

Contents

  • Map the template pieces
  • Snapshots through a debug bridge
  • Unit tests without a host app
  • Self-test in a running app
  • Moving to Swift 6

Map the template pieces

Template piece Existing Xcode or XcodeGen app
./build.sh make build, or xcodebuild -scheme <App> -configuration Release -derivedDataPath ~/Library/Developer/<App>-cli build
./build.sh --open Kill, copy to the same install path, lsregister -f -R -trusted, open
APP_SNAPSHOT mode A snapshot: command in a debug bridge (below)
APP_STORE=/tmp/... A data folder override, or a bridge command that only reads
swift test A test target with no host app (below)
--selftest launch flag A selftest bridge command (below)
Swift 6, default isolation Swift 5 mode: migrate (below) or keep it and annotate @MainActor

Write the mapping into the app's CLAUDE.md, and create the file if it is missing.

Snapshots through a debug bridge

A single-instance app (menu bar utility, background agent) cannot be launched a second time in snapshot mode. Add commands to its debug bridge (see the os-integrations skill, recipes.md):

  • snapshot:<file>:<match>: capture one of the app's own windows with ScreenCaptureKit, from inside the app:

    let content = try await SCShareableContent.current
    guard let scWindow = content.windows.first(where: { $0.windowID == CGWindowID(window.windowNumber) })
    else { return }
    let filter = SCContentFilter(desktopIndependentWindow: scWindow)
    let config = SCStreamConfiguration()
    config.width = Int(window.frame.width * 2); config.height = Int(window.frame.height * 2)
    let image = try await SCScreenshotManager.captureImage(contentFilter: filter, configuration: config)

    It shows glass, forms, and sidebars exactly as on screen, needs only the app's own Screen Recording grant, and never shows other apps.

  • Find windows in NSApp.windows. NSApp.orderedWindows skips panels. Match by title, or by root view type: String(describing: type(of: window.contentView!)) reads like NSHostingView<LauncherView>.

  • appearance:light|dark|system: set NSApp.appearance (not the saved preference), so one script snapshots every surface in both modes.

  • cacheDisplay(in:to:) is a fallback only. It draws forms, sidebars, and glass blank.

After a refactor, diff new snapshots against a baseline:

magick compare -metric AE -fuzz 8% before/settings.png after/settings.png /tmp/diff.png

Zero changed pixels proves the screen did not change. Small diffs on live data (clocks, stats) are fine.

Unit tests without a host app

An Xcode or XcodeGen app has no library target. Add a unit test target that compiles the pure logic files directly, with no host app:

# project.yml
<App>Tests:
  type: bundle.unit-test
  platform: macOS
  sources:
    - path: Tests
    - path: <App>/Features/Colors/ColorFormat.swift
    - path: <App>/Core/FuzzyMatch.swift

Give it its own scheme and run:

xcodebuild test -scheme <App>Tests -destination 'platform=macOS,arch=arm64'

-quiet prints nothing on success. Read the exit code.

A hosted test bundle launches a second copy of the app, which fights the running one for global hotkeys, the menu bar slot, event taps, and bridge notifications. Avoid it.

Logic buried in @MainActor stores cannot be compiled alone. Move it into its own file and type that takes plain values (text, not a URL; numbers, not a view).

Self-test in a running app

Make the self-test a bridge command that prints PASS or FAIL per check. Checks worth adding to any app:

  • Every action's Shortcuts title equals its menu title.
  • Every SF Symbol name exists: NSImage(systemSymbolName:accessibilityDescription:) != nil.
  • Every URL action name round-trips through the URL handler.
  • Smoke step: start every background timer, sampler, and observer for a few seconds, then print PASS. Only this catches crashes on background queues (see Moving to Swift 6).

Moving to Swift 6

  • Expect several build rounds. The compiler stops early, so the first error count is low. One app showed 9 errors first and about 22 errors and 28 warnings in the end.

  • The compiler-clean build can still crash at run time. A closure created inside a @MainActor type and handed to an API that does not take a @Sendable closure inherits the main actor. When the API runs it on a background queue, Swift 6 traps (dispatch_assert_queue). Find them:

    grep -rn 'setEventHandler\|setCancelHandler\|DispatchWorkItem\|addPeriodicTimeObserver\|AudioObjectAddPropertyListenerBlock' Sources/

    Mark each such closure { @Sendable in ... } and hop to the main actor inside it where needed. Then run the smoke step.

  • Common errors and fixes: see the swift-swiftui skill, "Swift 6 errors".

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts27d3 checks · Risk SAFE
  • Gen Agent Trust Hub27d

    The skill provides a workflow for building and verifying macOS apps using local scripts and standard developer tools. It includes safety advice to avoid using production databases for testing and describes the necessity of Screen Recording permissions for legitimate snapshot functionality.

  • Socket27d

    No alerts

  • Snyk27d

    Risk: LOW · No issues

Signed by skilld at 22dc792. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated last month
What it can do
Runs commands
All 1 allowed tools
Bash(./build.sh*) Bash(swift *) Bash(tools/*) Bash(*/Contents/MacOS/*) Bash(open *) Read

README badge

README badge for daveebbelaar/bama/build-and-verify