v1.6.1 release: Live Scratch Swift-toolchain detection + app icon

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-22 19:19:44 -07:00
parent 8eb64f883f
commit 90dc00f323
19 changed files with 411 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>";
@@ -111,7 +114,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1600;
LastUpgradeCheck = 2620;
LastUpgradeCheck = 2660;
TargetAttributes = {
C8D00000000000000000014 = {
CreatedOnToolsVersion = 16.0;
@@ -145,6 +148,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C8D00000000000000000041 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -166,6 +170,8 @@
C8D00000000000000000016 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
AUTOMATION_APPLE_EVENTS = NO;
CODE_SIGN_ENTITLEMENTS = LyrebirdScratch/LyrebirdScratch.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
@@ -173,7 +179,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 +209,14 @@
C8D00000000000000000017 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
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 +279,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 +343,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>
@@ -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
+21
View File
@@ -7,6 +7,27 @@ functionality in a backward-compatible way.
---
## 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