2 Commits

Author SHA1 Message Date
josh 9ec92277de v1.6.2 release: Live Scratch distributable/notarized app
Bundle Lyrebird swiftmodules + relocatable LyrebirdC module into the app so a
notarized, moved LyrebirdScratch.app can compile snippets off the build machine.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 20:13:47 -07:00
josh 90dc00f323 v1.6.1 release: Live Scratch Swift-toolchain detection + app icon
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 19:19:44 -07:00
20 changed files with 491 additions and 6 deletions
@@ -13,6 +13,7 @@
C8D00000000000000000022 /* LyrebirdLiveCompileUIDynamic in Frameworks */ = {isa = PBXBuildFile; productRef = C8D00000000000000000020 /* LyrebirdLiveCompileUIDynamic */; };
C8D00000000000000000034 /* LyrebirdLiveCompileUIDynamic in Embed Frameworks */ = {isa = PBXBuildFile; productRef = C8D00000000000000000020 /* LyrebirdLiveCompileUIDynamic */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
C8D00000000000000000036 /* LyrebirdDynamic in Embed Frameworks */ = {isa = PBXBuildFile; productRef = C8D0000000000000000001D /* LyrebirdDynamic */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
C8D00000000000000000041 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C8D00000000000000000040 /* Assets.xcassets */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -36,6 +37,7 @@
C8D00000000000000000007 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
C8D00000000000000000008 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
C8D00000000000000000009 /* LyrebirdScratch.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = LyrebirdScratch.entitlements; sourceTree = "<group>"; };
C8D00000000000000000040 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -74,6 +76,7 @@
C8D00000000000000000008 /* AppDelegate.swift */,
C8D00000000000000000006 /* Info.plist */,
C8D00000000000000000009 /* LyrebirdScratch.entitlements */,
C8D00000000000000000040 /* Assets.xcassets */,
);
path = LyrebirdScratch;
sourceTree = "<group>";
@@ -89,6 +92,7 @@
C8D00000000000000000012 /* Frameworks */,
C8D00000000000000000013 /* Resources */,
C8D00000000000000000035 /* Embed Frameworks */,
C8D00000000000000000042 /* Bundle Lyrebird swiftmodules */,
);
buildRules = (
);
@@ -111,7 +115,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1600;
LastUpgradeCheck = 2620;
LastUpgradeCheck = 2660;
TargetAttributes = {
C8D00000000000000000014 = {
CreatedOnToolsVersion = 16.0;
@@ -140,11 +144,30 @@
};
/* End PBXProject section */
/* Begin PBXShellScriptBuildPhase section */
C8D00000000000000000042 /* Bundle Lyrebird swiftmodules */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Bundle Lyrebird swiftmodules";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Bundle the Lyrebird module artifacts into the app so the live-compile scratchpad\n# can `import LyrebirdSynth` / `import LyrebirdLiveCompile` on any machine — they\n# otherwise resolve only from BUILT_PRODUCTS_DIR / the dev source tree, both absent\n# once the .app is exported. LiveSession stages Contents/Resources/LyrebirdArtifacts\n# at launch; artifactSourceDir() / discoverSPMModuleMaps() then find them.\nset -e\nART=\"${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/Resources/LyrebirdArtifacts\"\nDEST=\"${ART}/Modules\"\n/bin/rm -rf \"${ART}\"\n/bin/mkdir -p \"${DEST}\"\n# 1. Swift module interfaces the snippet imports (+ their transitive deps).\nfor m in LyrebirdSynth LyrebirdLiveCompile LyrebirdLiveCompileUI LyrebirdGraphDSLEmbedded; do\n SRC=\"${BUILT_PRODUCTS_DIR}/${m}.swiftmodule\"\n if [ -e \"${SRC}\" ]; then /bin/cp -R \"${SRC}\" \"${DEST}/\"; fi\ndone\n# 2. LyrebirdC C-shim Clang module (LyrebirdSynth depends on it; a snippet importing\n# LyrebirdSynth needs its module map + header). The SPM source map uses a header path\n# relative to the map dir, so map + include/ copied together stay self-contained and\n# relocatable — placed at LyrebirdArtifacts/LyrebirdC.build so discoverSPMModuleMaps()\n# finds it once staged.\nCSRC=\"${SRCROOT}/../../Sources/LyrebirdC\"\nif [ -f \"${CSRC}/module.modulemap\" ]; then\n CDEST=\"${ART}/LyrebirdC.build\"\n /bin/mkdir -p \"${CDEST}\"\n /bin/cp \"${CSRC}/module.modulemap\" \"${CDEST}/\"\n [ -d \"${CSRC}/include\" ] && /bin/cp -R \"${CSRC}/include\" \"${CDEST}/\"\nfi\necho \"Bundled Lyrebird modules + LyrebirdC shim into ${ART}\"\n";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXResourcesBuildPhase section */
C8D00000000000000000013 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C8D00000000000000000041 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -166,6 +189,9 @@
C8D00000000000000000016 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
AUTOMATION_APPLE_EVENTS = NO;
CODE_SIGN_ENTITLEMENTS = LyrebirdScratch/LyrebirdScratch.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
@@ -173,7 +199,6 @@
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = HE5VJFE9E4;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_RESOURCE_ACCESS_AUDIO_INPUT = YES;
ENABLE_RESOURCE_ACCESS_CALENDARS = NO;
@@ -204,13 +229,15 @@
C8D00000000000000000017 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
AUTOMATION_APPLE_EVENTS = NO;
CODE_SIGN_ENTITLEMENTS = LyrebirdScratch/LyrebirdScratch.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = HE5VJFE9E4;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_RESOURCE_ACCESS_AUDIO_INPUT = YES;
ENABLE_RESOURCE_ACCESS_CALENDARS = NO;
@@ -273,6 +300,7 @@
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = HE5VJFE9E4;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
@@ -336,6 +364,7 @@
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = HE5VJFE9E4;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
@@ -0,0 +1,15 @@
{
"images" : [
{ "idiom" : "mac", "scale" : "1x", "size" : "16x16", "filename" : "icon_16.png" },
{ "idiom" : "mac", "scale" : "2x", "size" : "16x16", "filename" : "icon_32.png" },
{ "idiom" : "mac", "scale" : "1x", "size" : "32x32", "filename" : "icon_32.png" },
{ "idiom" : "mac", "scale" : "2x", "size" : "32x32", "filename" : "icon_64.png" },
{ "idiom" : "mac", "scale" : "1x", "size" : "128x128", "filename" : "icon_128.png" },
{ "idiom" : "mac", "scale" : "2x", "size" : "128x128", "filename" : "icon_256.png" },
{ "idiom" : "mac", "scale" : "1x", "size" : "256x256", "filename" : "icon_256.png" },
{ "idiom" : "mac", "scale" : "2x", "size" : "256x256", "filename" : "icon_512.png" },
{ "idiom" : "mac", "scale" : "1x", "size" : "512x512", "filename" : "icon_512.png" },
{ "idiom" : "mac", "scale" : "2x", "size" : "512x512", "filename" : "icon_1024.png" }
],
"info" : { "author" : "xcode", "version" : 1 }
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 338 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

@@ -0,0 +1,3 @@
{
"info" : { "author" : "xcode", "version" : 1 }
}
@@ -13,14 +13,14 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.6.1</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2026 Realized Sound. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
@@ -164,6 +164,14 @@ extension LiveSession {
try? fm.copyItem(at: dylib, to: staging.appendingPathComponent(dylib.lastPathComponent))
}
// 2.5. Self-contained C-shim module dirs (`<Module>.build/` holding a
// `module.modulemap` whose header path is relative to the map — as shipped
// in the app bundle's LyrebirdArtifacts). Copy the whole dir verbatim so the
// relative header resolves at the staged location; no path rewrite needed.
// (The absolute-`umbrella header` dev-build maps are handled separately in
// step 3 — a relative-header map is skipped there, so no double-write.)
copySelfContainedModuleMapDirs(from: src, writeInto: staging)
// 3. C module maps + their umbrella headers. Files are written under the
// temp `staging` dir, but the umbrella path baked into each map must
// reference the FINAL `dest` (where they land after the atomic swap) —
@@ -232,6 +240,32 @@ extension LiveSession {
/// occupy after the caller's atomic swap of `writeInto` onto `finalRoot`.
/// Best-effort per map: a map with no resolvable umbrella header, or one that
/// fails to copy, is skipped without aborting the rest.
/// Copy each `<Module>.build/` directory under `src` that holds a
/// `module.modulemap` **without** an `umbrella header` directive — i.e. a
/// self-contained map whose `header "…"` path is relative to the map's own
/// directory (as bundled in the app's `LyrebirdArtifacts`). The whole dir is
/// copied verbatim (map + adjacent headers), so the relative path resolves at
/// the staged location and `discoverSPMModuleMaps` finds the copied map. Maps
/// with an absolute `umbrella header` are left for ``stageClangModuleMaps``.
private static func copySelfContainedModuleMapDirs(from src: URL, writeInto staging: URL) {
let fm: FileManager = FileManager.default
guard let entries: [URL] = try? fm.contentsOfDirectory(
at: src,
includingPropertiesForKeys: nil
) else { return }
for buildDir: URL in entries where buildDir.pathExtension == "build" {
let map: URL = buildDir.appendingPathComponent("module.modulemap", isDirectory: false)
guard fm.fileExists(atPath: map.path),
let text: String = try? String(contentsOf: map, encoding: .utf8),
umbrellaHeaderPath(in: text) == nil // self-contained (relative header) only
else { continue }
let stagedDir: URL = staging.appendingPathComponent(buildDir.lastPathComponent, isDirectory: true)
try? fm.removeItem(at: stagedDir)
try? fm.copyItem(at: buildDir, to: stagedDir)
}
}
private static func stageClangModuleMaps(from src: URL, writeInto staging: URL, finalRoot dest: URL) {
let fm: FileManager = FileManager.default
guard let entries: [URL] = try? fm.contentsOfDirectory(
@@ -0,0 +1,26 @@
// SwiftToolchainStatus.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
#if os(macOS)
/// Result of probing for a usable Swift toolchain (the Swift scratchpad compiles
/// snippets by shelling out to `swiftc`, which requires Xcode or the Command Line
/// Tools). The Graph DSL mode does not need a toolchain, so a `.missing*` status is
/// a soft condition — it gates only the Swift-compile path. Produced by ``ToolchainProbe``.
public enum SwiftToolchainStatus: Equatable, Sendable {
/// `swiftc` and the macOS SDK both resolve — the Swift scratchpad can compile.
case available
/// No developer tools at all (`xcode-select -p` fails and `swiftc` is unresolved).
/// Fix: install the Command Line Tools (`xcode-select --install`) or Xcode.
case missingDeveloperTools
/// A developer directory is selected but `swiftc` could not be resolved.
/// Fix: install/repair Xcode or the Command Line Tools.
case missingSwiftc
/// `swiftc` resolves but the macOS SDK does not — usually an incomplete Xcode.
/// Fix: install a full Xcode.
case missingSDK
}
#endif
@@ -0,0 +1,85 @@
// ToolchainProbe.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
#if os(macOS)
import Foundation
/// Detects whether a usable Swift toolchain is present, so the app can warn the user
/// (with install guidance) instead of only failing into the console on the first Run.
///
/// The resolvers are injectable so the `.missing*` branches can be unit-tested without
/// actually uninstalling the toolchain; the defaults wrap the real `LiveCompiler`
/// resolution (`xcrun -f swiftc`, `xcrun --show-sdk-path`) plus `xcode-select -p`.
///
/// **Not RT-related.** Runs `xcrun` / `xcode-select` subprocesses — call off the main
/// thread (a couple of fast execs).
public struct ToolchainProbe: Sendable {
private let swiftcResolver: @Sendable () -> String?
private let sdkResolver: @Sendable () -> String?
private let developerDirResolver: @Sendable () -> String?
/// - Parameters:
/// - swiftcResolver: Returns the `swiftc` path, or `nil` when unresolved.
/// - sdkResolver: Returns the macOS SDK path, or `nil` when unresolved.
/// - developerDirResolver: Returns the active developer dir (`xcode-select -p`),
/// or `nil` when no developer directory is configured.
public init(
swiftcResolver: @escaping @Sendable () -> String? = ToolchainProbe.defaultSwiftcResolver,
sdkResolver: @escaping @Sendable () -> String? = ToolchainProbe.defaultSDKResolver,
developerDirResolver: @escaping @Sendable () -> String? = ToolchainProbe.developerDirViaXcodeSelect
) {
self.swiftcResolver = swiftcResolver
self.sdkResolver = sdkResolver
self.developerDirResolver = developerDirResolver
}
/// Default `swiftc` resolver — wraps the internal `LiveCompiler.findSwiftc()` so the
/// public `init` default argument does not reference internal API.
public static func defaultSwiftcResolver() -> String? { try? LiveCompiler.findSwiftc() }
/// Default macOS SDK resolver — wraps the internal `LiveCompiler.sdkPathViaXcrun()`.
public static func defaultSDKResolver() -> String? { LiveCompiler.sdkPathViaXcrun() }
/// Classify the current toolchain state.
public func status() -> SwiftToolchainStatus {
let swiftc: String? = swiftcResolver()
let sdk: String? = sdkResolver()
if swiftc != nil && sdk != nil { return .available }
if swiftc == nil {
// No swiftc: distinguish "no developer tools at all" from "tools present
// but swiftc unresolved" by whether a developer dir is configured.
return developerDirResolver() == nil ? .missingDeveloperTools : .missingSwiftc
}
// swiftc resolves but the SDK does not.
return .missingSDK
}
/// Active developer directory via `xcode-select -p`, or `nil` when unset / xcode-select
/// is missing / returns non-zero.
public static func developerDirViaXcodeSelect() -> String? {
let xcodeSelectPath: String = "/usr/bin/xcode-select"
guard FileManager.default.isExecutableFile(atPath: xcodeSelectPath) else { return nil }
let process: Process = Process()
process.executableURL = URL(fileURLWithPath: xcodeSelectPath)
process.arguments = ["-p"]
let stdout: Pipe = Pipe()
process.standardOutput = stdout
process.standardError = FileHandle.nullDevice
do {
try process.run()
process.waitUntilExit()
} catch {
return nil
}
guard process.terminationStatus == 0 else { return nil }
let data: Data = stdout.fileHandleForReading.readDataToEndOfFile()
guard let raw: String = String(data: data, encoding: .utf8) else { return nil }
let trimmed: String = raw.trimmingCharacters(in: .whitespacesAndNewlines)
return trimmed.isEmpty ? nil : trimmed
}
}
#endif
@@ -19,6 +19,13 @@ The view is macOS-only — `LyrebirdLiveCompile` shells out to `swiftc`, which i
unavailable on iOS. The nested `LiveCompile/` sub-package declares
`platforms: [.macOS(.v15)]` and cannot be added to an iOS target.
> Note: **Swift mode needs a Swift toolchain** (Xcode or the Command Line Tools) —
> it compiles snippets with `swiftc`. At launch the app probes for one
> (`ToolchainProbe`) and, if none is found, shows an alert (once per launch) with
> install guidance (Install Command Line Tools / Get Xcode). **Graph DSL mode needs no
> toolchain** — it interprets generator-graph expressions in-process — so it's the
> zero-install fallback.
## Hosting
```swift
@@ -39,6 +39,11 @@ public final class LyrebirdScratchMenuController: NSObject, NSMenuItemValidation
mainMenu.addItem(windowMenuItem())
NSApplication.shared.mainMenu = mainMenu
// Launch check: if the Swift toolchain is missing, warn with install guidance
// (the Swift scratchpad needs swiftc). Fires once per launch — the probe runs
// off-main and the alert (if any) is dispatched back to the main thread.
warnIfSwiftToolchainMissing()
}
// MARK: App menu
@@ -0,0 +1,141 @@
// ToolchainAlert.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
#if os(macOS)
import AppKit
import LyrebirdLiveCompile
/// User-facing text for a missing-toolchain warning. Pure/value type so the
/// status → message mapping is unit-testable without presenting a modal.
public struct ToolchainAlertContent: Equatable {
/// Alert title (the `NSAlert.messageText`).
public let title: String
/// Alert body explaining the problem and the fix (the `NSAlert.informativeText`).
public let message: String
/// Whether "Install Command Line Tools" is an appropriate remedy (it is for a
/// missing toolchain, but not for a present-but-incomplete SDK).
public let offersCommandLineToolsInstall: Bool
}
/// Map a toolchain status to alert content, or `nil` when nothing needs saying
/// (`.available`). Pure — no side effects.
public func toolchainAlertContent(for status: SwiftToolchainStatus) -> ToolchainAlertContent? {
let dslNote: String = " The Graph DSL mode works without a toolchain if you'd rather not install one."
switch status {
case .available:
return nil
case .missingDeveloperTools:
return ToolchainAlertContent(
title: "Swift toolchain not found",
message: "The Swift scratchpad compiles snippets with swiftc, which needs "
+ "Xcode or the Command Line Tools." + dslNote,
offersCommandLineToolsInstall: true
)
case .missingSwiftc:
return ToolchainAlertContent(
title: "Swift compiler not found",
message: "A developer directory is selected, but swiftc could not be resolved. "
+ "Install or repair Xcode or the Command Line Tools." + dslNote,
offersCommandLineToolsInstall: true
)
case .missingSDK:
return ToolchainAlertContent(
title: "macOS SDK not found",
message: "swiftc was found but the macOS SDK is missing — your Xcode may be "
+ "incomplete. Install a full Xcode." + dslNote,
offersCommandLineToolsInstall: false
)
}
}
/// App Store product page for Xcode.
private let xcodeAppStoreURL: String = "macappstore://apps.apple.com/app/xcode/id497799835"
@MainActor
extension LyrebirdScratchMenuController {
/// Probe for a Swift toolchain off the main thread and, if missing, present a
/// one-time warning alert with install guidance. Safe no-op when the toolchain is
/// available. Called once at launch from `installMainMenu`.
public func warnIfSwiftToolchainMissing(probe: ToolchainProbe = ToolchainProbe()) {
DispatchQueue.global(qos: .utility).async {
let status: SwiftToolchainStatus = probe.status()
guard let content: ToolchainAlertContent = toolchainAlertContent(for: status) else { return }
DispatchQueue.main.async {
LyrebirdScratchMenuController.presentToolchainAlert(content)
}
}
}
/// Present the toolchain warning as a modal `NSAlert` with install actions.
static func presentToolchainAlert(_ content: ToolchainAlertContent) {
let alert: NSAlert = NSAlert()
alert.messageText = content.title
alert.informativeText = content.message
alert.alertStyle = .warning
// Buttons are added in first→last order; NSAlert returns .alertFirstButtonReturn
// for the first, +1 for the next, etc.
let installButton: NSButton? = content.offersCommandLineToolsInstall
? alert.addButton(withTitle: "Install Command Line Tools")
: nil
let xcodeButton: NSButton = alert.addButton(withTitle: "Get Xcode")
let okButton: NSButton = alert.addButton(withTitle: "OK")
// Make OK the default (Return) so an accidental Return dismisses rather than
// launching the installer / App Store. Clearing the other buttons' key
// equivalents removes their default-button status.
installButton?.keyEquivalent = ""
xcodeButton.keyEquivalent = ""
okButton.keyEquivalent = "\r"
let response: NSApplication.ModalResponse = alert.runModal()
let firstButton: NSApplication.ModalResponse = .alertFirstButtonReturn
let secondButton: NSApplication.ModalResponse =
NSApplication.ModalResponse(rawValue: firstButton.rawValue + 1)
if content.offersCommandLineToolsInstall {
if response == firstButton {
launchCommandLineToolsInstaller()
} else if response == secondButton {
openXcodeInAppStore()
}
// third button = OK: dismiss.
} else {
if response == firstButton {
openXcodeInAppStore()
}
// second button = OK: dismiss.
}
}
/// Launch Apple's Command Line Tools installer (`xcode-select --install`). This
/// opens Apple's own GUI installer dialog — the app never installs silently.
private static func launchCommandLineToolsInstaller() {
let xcodeSelectPath: String = "/usr/bin/xcode-select"
// Mirror the executable-file pre-check used by the other subprocess helpers.
guard FileManager.default.isExecutableFile(atPath: xcodeSelectPath) else {
openXcodeInAppStore()
return
}
let process: Process = Process()
process.executableURL = URL(fileURLWithPath: xcodeSelectPath)
process.arguments = ["--install"]
do {
try process.run()
} catch {
// If we can't launch it, fall back to the App Store (Xcode includes the tools).
openXcodeInAppStore()
}
}
/// Open Xcode's App Store product page.
private static func openXcodeInAppStore() {
guard let url: URL = URL(string: xcodeAppStoreURL) else { return }
NSWorkspace.shared.open(url)
}
}
#endif
@@ -0,0 +1,54 @@
// ToolchainProbeTests.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
#if os(macOS)
import Testing
@testable import LyrebirdLiveCompile
@Suite("ToolchainProbe")
struct ToolchainProbeTests {
private func probe(swiftc: String?, sdk: String?, devDir: String?) -> ToolchainProbe {
ToolchainProbe(
swiftcResolver: { swiftc },
sdkResolver: { sdk },
developerDirResolver: { devDir }
)
}
@Test("swiftc + SDK both present → available")
func availableWhenBothResolve() {
#expect(probe(swiftc: "/usr/bin/swiftc", sdk: "/SDK", devDir: "/Dev").status() == .available)
}
@Test("no swiftc and no developer dir → missingDeveloperTools")
func missingDeveloperTools() {
#expect(probe(swiftc: nil, sdk: nil, devDir: nil).status() == .missingDeveloperTools)
}
@Test("no swiftc but developer dir present → missingSwiftc")
func missingSwiftc() {
#expect(probe(swiftc: nil, sdk: nil, devDir: "/Dev").status() == .missingSwiftc)
// SDK value is irrelevant when swiftc is unresolved.
#expect(probe(swiftc: nil, sdk: "/SDK", devDir: "/Dev").status() == .missingSwiftc)
}
@Test("swiftc present but SDK missing → missingSDK")
func missingSDK() {
#expect(probe(swiftc: "/usr/bin/swiftc", sdk: nil, devDir: "/Dev").status() == .missingSDK)
}
@Test("default probe on a build machine finds developer tools")
func defaultProbeFindsDeveloperTools() {
// Any machine that can build/test this package has a developer directory, so
// the real (non-injected) resolvers must never report missingDeveloperTools —
// this smoke-tests that the default xcode-select / xcrun probes actually run.
// (Not asserting strict `.available`: a full-SDK requirement would couple the
// suite to the host's exact toolchain completeness.)
#expect(ToolchainProbe().status() != .missingDeveloperTools)
}
}
#endif
@@ -0,0 +1,40 @@
// ToolchainAlertTests.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
#if os(macOS)
import Testing
import LyrebirdLiveCompile
@testable import LyrebirdLiveCompileUI
@Suite("ToolchainAlert content")
struct ToolchainAlertTests {
@Test("available status produces no alert content")
func availableIsNil() {
#expect(toolchainAlertContent(for: .available) == nil)
}
@Test("missing-toolchain statuses offer the Command Line Tools install")
func missingOffersCLTInstall() {
for status: SwiftToolchainStatus in [.missingDeveloperTools, .missingSwiftc] {
let content: ToolchainAlertContent? = toolchainAlertContent(for: status)
#expect(content != nil)
#expect(content?.offersCommandLineToolsInstall == true)
#expect(content?.title.isEmpty == false)
// Steers the user to the dependency-free fallback.
#expect(content?.message.contains("Graph DSL") == true)
}
}
@Test("missing-SDK does not offer CLT install (needs a full Xcode)")
func missingSDKNoCLT() {
let content: ToolchainAlertContent? = toolchainAlertContent(for: .missingSDK)
#expect(content != nil)
#expect(content?.offersCommandLineToolsInstall == false)
#expect(content?.message.contains("Xcode") == true)
}
}
#endif
+46
View File
@@ -7,6 +7,52 @@ functionality in a backward-compatible way.
---
## 1.6.2 — Live Scratch: distributable / notarized app
A patch release. Live Scratch packaging only; no library API changes.
A notarized, moved-off-the-build-machine `LyrebirdScratch.app` could not compile
snippets — the Swift scratchpad shells out to `swiftc`, and the modules it needs
(`LyrebirdSynth`, `LyrebirdLiveCompile`, and the `LyrebirdC` C-shim they depend on)
lived only in the dev build tree. Two failures surfaced in order — `no such module
'LyrebirdSynth'`, then `missing required module 'LyrebirdC'`. Both are now fixed:
- **Swiftmodules bundled** — a build phase copies the Lyrebird `.swiftmodule`s into
`Resources/LyrebirdArtifacts/Modules` inside the app, and the live compiler adds
that directory to its import search path.
- **LyrebirdC module relocatable** — the SPM *source* `module.modulemap` (relative
header path, so map + `include/` are self-contained) is bundled into
`LyrebirdArtifacts/LyrebirdC.build/`, and staging copies relative-header module
maps verbatim so the Clang module resolves from the bundle rather than the
absolute dev path Xcode's generated map baked in.
Verified end-to-end: a snippet compile resolving modules **only** from the app
bundle typechecks clean, and the notarized app runs the Swift scratchpad on a
machine without the dev tree.
---
## 1.6.1 — Live Scratch: Swift-toolchain detection
A patch release. Live Scratch quality-of-life; no library API changes.
The Swift scratchpad compiles snippets by shelling out to `swiftc` (Xcode or the
Command Line Tools). Previously a missing toolchain only surfaced as a compile
error in the console on the first Run. Now the app **detects it at launch** and
shows an alert with actionable install guidance:
- **Install Command Line Tools** — launches Apple's own installer (`xcode-select
--install`); the app never installs anything silently.
- **Get Xcode** — opens the App Store product page.
The check is alert-only and never blocks the app: the **Graph DSL mode needs no
toolchain**, so it's the zero-install fallback. (`ToolchainProbe` classifies the
toolchain into available / missing-developer-tools / missing-swiftc / missing-SDK,
with injectable resolvers so the missing states are unit-tested without uninstalling
anything.)
---
## 1.6.0 — Soundfile format expansion
A minor release. Backward-compatible — the existing default write formats are