v1.6.3 release: notarization-ready macos-ui-xcode template

Scaffolded macOS app now ships audio-input entitlement + mic usage string
under Hardened Runtime (unsandboxed for performance), and compiles under
Swift 6 (NoteController/AppDelegate marked @MainActor).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-23 08:38:41 -07:00
parent 9ec92277de
commit 5e6534a615
7 changed files with 149 additions and 27 deletions
@@ -41,6 +41,7 @@ extension ProjectScaffolder {
/* Begin PBXFileReference section */
\t\t\(pbxAppProductRef) /* \(name).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = \(name).app; sourceTree = BUILT_PRODUCTS_DIR; };
\t\t\(pbxInfoPlistRef) /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
\t\t\(pbxAppEntitlementsRef) /* \(name).entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = \(name).entitlements; sourceTree = "<group>"; };
\t\t\(pbxMainSwiftRef) /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
\t\t\(pbxAppDelegateRef) /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
\t\t\(pbxSynthRef) /* \(name)Synth.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \(name)Synth.swift; sourceTree = "<group>"; };
@@ -85,6 +86,7 @@ extension ProjectScaffolder {
\t\t\t\t\(pbxNoteControllerRef) /* NoteController.swift */,
\t\t\t\t\(pbxViewRef) /* \(name)View.swift */,
\t\t\t\t\(pbxInfoPlistRef) /* Info.plist */,
\t\t\t\t\(pbxAppEntitlementsRef) /* \(name).entitlements */,
\t\t\t);
\t\t\tpath = \(name);
\t\t\tsourceTree = "<group>";
@@ -177,6 +179,7 @@ extension ProjectScaffolder {
\t\t\(pbxAppDebugConfig) /* Debug */ = {
\t\t\tisa = XCBuildConfiguration;
\t\t\tbuildSettings = {
\t\t\t\tCODE_SIGN_ENTITLEMENTS = \(name)/\(name).entitlements;
\t\t\t\tCODE_SIGN_STYLE = Automatic;
\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;
\t\t\t\tDEAD_CODE_STRIPPING = YES;
@@ -197,6 +200,7 @@ extension ProjectScaffolder {
\t\t\(pbxAppReleaseConfig) /* Release */ = {
\t\t\tisa = XCBuildConfiguration;
\t\t\tbuildSettings = {
\t\t\t\tCODE_SIGN_ENTITLEMENTS = \(name)/\(name).entitlements;
\t\t\t\tCODE_SIGN_STYLE = Automatic;
\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;
\t\t\t\tDEAD_CODE_STRIPPING = YES;
@@ -122,6 +122,8 @@ extension ProjectScaffolder {
let files: [(String, String)] = [
((appGroupDir as NSString).appendingPathComponent("Info.plist"),
macOSAppInfoPlist(name: name)),
((appGroupDir as NSString).appendingPathComponent("\(name).entitlements"),
macOSAppEntitlements()),
((appGroupDir as NSString).appendingPathComponent("main.swift"),
macOSAppMainSwift(name: name)),
((appGroupDir as NSString).appendingPathComponent("AppDelegate.swift"),
@@ -146,6 +148,35 @@ extension ProjectScaffolder {
appInfoPlist(name: name, platform: .macOS)
}
/// Entitlements for the standalone macOS performance app.
///
/// Not sandboxed — a live-performance app needs unrestricted access to
/// audio devices, files (buffer load/render), MIDI, and OSC networking,
/// which the App Sandbox would gate. The one entitlement granted is
/// microphone / line-in: under the Hardened Runtime (enabled in the
/// pbxproj, and required for notarization) the OS hard-kills the process
/// the moment the AUHAL input bus opens unless this is present. It only
/// prompts the user when input is actually opened
/// (`numInputChannels > 0`), so it is harmless for output-only synths.
///
/// If a project needs to load dynamic libraries signed by a different
/// team (e.g. a bundled `.dylib`), add
/// `com.apple.security.cs.disable-library-validation`. If it must ship on
/// the Mac App Store, add `com.apple.security.app-sandbox` and the
/// specific resource entitlements the piece uses instead.
static func macOSAppEntitlements() -> String {
"""
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.device.audio-input</key>
<true/>
</dict>
</plist>
"""
}
static func macOSAppMainSwift(name: String) -> String {
"""
// \(name) — entry point
@@ -178,6 +209,9 @@ extension ProjectScaffolder {
import LyrebirdSynth
import LyrebirdUI
/// `@MainActor`: constructs the main-actor `NoteController` and synth,
/// and `NSApplicationDelegate` callbacks already run on the main actor.
@MainActor
final class AppDelegate: NSObject, NSApplicationDelegate {
let engine: SynthesisEngine
let controller: NoteController
@@ -246,6 +280,11 @@ extension ProjectScaffolder {
/// Owns engine + synth + scope; mediates start/stop from the UI so the
/// engine isn't kicked until user is ready (avoids first-block dropouts).
///
/// `@MainActor`: this drives SwiftUI and calls the engine's
/// main-actor-isolated `add(_:)`, so the whole controller lives on the
/// main actor.
@MainActor
@Observable
final class NoteController {
@@ -385,9 +424,15 @@ extension ProjectScaffolder {
case .macOS:
minOSKey = "LSMinimumSystemVersion"
minOSValue = "$(MACOSX_DEPLOYMENT_TARGET)"
// The mic usage string is required whenever the app opens the
// AUHAL input bus: macOS crashes a Hardened-Runtime process on
// audio-input access if this key is absent. Harmless for
// output-only synths (no prompt fires until input opens).
extras = """
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSMicrophoneUsageDescription</key>
<string>\(name) uses audio input for live signal processing.</string>
"""
case .iOS:
minOSKey = "MinimumOSVersion"