prep for 1.2.0 release updates
This commit is contained in:
@@ -30,6 +30,20 @@ public enum ProjectTemplate: String, CaseIterable, Equatable {
|
||||
/// AUv3 host `.app` + `aumu` plugin extension wrapping a Lyrebird synth.
|
||||
/// Generates a full `<name>.xcodeproj` with two targets and entitlements files.
|
||||
case auv3 = "auv3"
|
||||
/// macOS guitar-pedalboard starter app built on `LyrebirdShoeGaze`.
|
||||
/// Generates a full `<name>.xcodeproj` with a SwiftUI `@main App` entry
|
||||
/// point, an `@Observable` app model wiring `CoreAudioDriver` + `ShoeGaze`,
|
||||
/// a root `ShoeGazeView`, and an **Audio ▸ Mute ⌘M** menu command.
|
||||
/// Requires `--shoegaze-path` (or a published ShoeGaze URL) in addition to
|
||||
/// the normal `--lyrebird-path`.
|
||||
case shoegaze = "shoegaze"
|
||||
/// iOS guitar-pedalboard starter app built on `LyrebirdShoeGaze`.
|
||||
/// Generates a full `<name>.xcodeproj` with a SwiftUI `@main App` entry
|
||||
/// point, an `@Observable` app model wiring `iOSAudioDriver` +
|
||||
/// `AVAudioSession` + `ShoeGaze`, and a root `ShoeGazeView`.
|
||||
/// Requires `--shoegaze-path` (or a published ShoeGaze URL) in addition to
|
||||
/// the normal `--lyrebird-path`.
|
||||
case shoegazeIOS = "shoegaze-ios"
|
||||
|
||||
/// Case-insensitive init from a raw string. Accepts hyphen-free aliases too.
|
||||
public init?(string: String) {
|
||||
@@ -46,19 +60,24 @@ public enum ProjectTemplate: String, CaseIterable, Equatable {
|
||||
self = .iosUI
|
||||
case "auv3", "au-v3", "au_v3":
|
||||
self = .auv3
|
||||
case "shoegaze", "shoe-gaze", "shoe_gaze":
|
||||
self = .shoegaze
|
||||
case "shoegaze-ios", "shoegazeios", "shoegaze_ios":
|
||||
self = .shoegazeIOS
|
||||
default: return nil
|
||||
}
|
||||
}
|
||||
|
||||
/// True when the template emits a full `.xcodeproj` skeleton in addition
|
||||
/// to the Swift Package. The simpler four templates (basic/demo/ui-demo/nrt)
|
||||
/// rely on Xcode's "Open Package.swift" path; these three need a real
|
||||
/// `.xcodeproj` because they ship an `.app` bundle, app entitlements, or
|
||||
/// (auv3) an `.appex` extension target — none of which SwiftPM can express.
|
||||
/// to the Swift Package. The simpler templates (basic/demo/ui-demo/nrt/score)
|
||||
/// rely on Xcode's "Open Package.swift" path; the Xcode-bearing templates
|
||||
/// need a real `.xcodeproj` because they ship an `.app` bundle, app
|
||||
/// entitlements, or (auv3) an `.appex` extension target — none of which
|
||||
/// SwiftPM can express.
|
||||
public var shipsXcodeProject: Bool {
|
||||
switch self {
|
||||
case .basic, .demo, .uiDemo, .nrt, .score: return false
|
||||
case .macosUIXcode, .iosUI, .auv3: return true
|
||||
case .shoegaze, .macosUIXcode, .iosUI, .auv3, .shoegazeIOS: return true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,12 +171,16 @@ public enum ProjectScaffolder {
|
||||
/// *before* calling this (see `LyrebirdCLI.runNew`), so default
|
||||
/// scaffolds track current `main`; direct library callers get the
|
||||
/// documented `nil` → remote behaviour.
|
||||
/// - shoegazePath: Absolute path to a local ShoeGaze checkout. Only
|
||||
/// consumed by the `shoegaze` template. `nil` → emit a remote-URL
|
||||
/// placeholder in the generated `Package.swift`.
|
||||
/// - Throws: `ProjectScaffolder.Error` on name validation failure or file system errors.
|
||||
public static func scaffold(
|
||||
name: String,
|
||||
template: ProjectTemplate = .basic,
|
||||
in parentDirectory: String = FileManager.default.currentDirectoryPath,
|
||||
lyrebirdPath: String? = nil
|
||||
lyrebirdPath: String? = nil,
|
||||
shoegazePath: String? = nil
|
||||
) throws {
|
||||
try validateName(name)
|
||||
|
||||
@@ -182,12 +205,14 @@ public enum ProjectScaffolder {
|
||||
template: template,
|
||||
projectRoot: projectRoot,
|
||||
lyrebirdPath: lyrebirdPath,
|
||||
shoegazePath: shoegazePath,
|
||||
fm: fm)
|
||||
} else {
|
||||
try scaffoldSwiftPackage(name: name,
|
||||
template: template,
|
||||
projectRoot: projectRoot,
|
||||
lyrebirdPath: lyrebirdPath,
|
||||
shoegazePath: shoegazePath,
|
||||
fm: fm)
|
||||
}
|
||||
}
|
||||
@@ -199,6 +224,7 @@ public enum ProjectScaffolder {
|
||||
template: ProjectTemplate,
|
||||
projectRoot: String,
|
||||
lyrebirdPath: String?,
|
||||
shoegazePath: String? = nil,
|
||||
fm: FileManager
|
||||
) throws {
|
||||
let sourcesDir: String = (projectRoot as NSString)
|
||||
@@ -223,7 +249,12 @@ public enum ProjectScaffolder {
|
||||
var files: [(path: String, content: String)] = [
|
||||
(
|
||||
(projectRoot as NSString).appendingPathComponent("Package.swift"),
|
||||
packageManifest(name: name, template: template, lyrebirdPath: lyrebirdPath)
|
||||
packageManifest(
|
||||
name: name,
|
||||
template: template,
|
||||
lyrebirdPath: lyrebirdPath,
|
||||
shoegazePath: shoegazePath
|
||||
)
|
||||
),
|
||||
(
|
||||
(sourcesDir as NSString).appendingPathComponent("main.swift"),
|
||||
@@ -263,6 +294,7 @@ public enum ProjectScaffolder {
|
||||
template: ProjectTemplate,
|
||||
projectRoot: String,
|
||||
lyrebirdPath: String?,
|
||||
shoegazePath: String? = nil,
|
||||
fm: FileManager
|
||||
) throws {
|
||||
// Every xcode-bearing template ships an `<name>.xcworkspace` that
|
||||
@@ -289,6 +321,10 @@ public enum ProjectScaffolder {
|
||||
fm: fm, projectRoot: projectRoot)
|
||||
|
||||
switch template {
|
||||
case .shoegaze:
|
||||
try writeShoeGazeMacOSFiles(name: name, projectRoot: projectRoot,
|
||||
lyrebirdPath: lyrebirdPath,
|
||||
shoegazePath: shoegazePath, fm: fm)
|
||||
case .macosUIXcode:
|
||||
try writeMacOSUIXcodeFiles(name: name, projectRoot: projectRoot,
|
||||
lyrebirdPath: lyrebirdPath, fm: fm)
|
||||
@@ -298,6 +334,10 @@ public enum ProjectScaffolder {
|
||||
case .auv3:
|
||||
try writeAUv3Files(name: name, projectRoot: projectRoot,
|
||||
lyrebirdPath: lyrebirdPath, fm: fm)
|
||||
case .shoegazeIOS:
|
||||
try writeShoeGazeIOSFiles(name: name, projectRoot: projectRoot,
|
||||
lyrebirdPath: lyrebirdPath,
|
||||
shoegazePath: shoegazePath, fm: fm)
|
||||
case .basic, .demo, .uiDemo, .nrt, .score:
|
||||
// Unreachable — shipsXcodeProject filters these out at dispatch.
|
||||
try? fm.removeItem(atPath: projectRoot)
|
||||
@@ -359,10 +399,14 @@ public enum ProjectScaffolder {
|
||||
/// nil, falls back to the published Git URL (``lyrebirdPackageURL``).
|
||||
/// Used by `lyrebird new --lyrebird-path` for users who don't yet
|
||||
/// have access to the public repository.
|
||||
/// - shoegazePath: When non-nil and template is `.shoegaze`, the
|
||||
/// ShoeGaze package is declared as a local SPM dependency at this
|
||||
/// absolute path. When nil, a remote-URL placeholder is emitted.
|
||||
public static func packageManifest(
|
||||
name: String,
|
||||
template: ProjectTemplate = .basic,
|
||||
lyrebirdPath: String? = nil
|
||||
lyrebirdPath: String? = nil,
|
||||
shoegazePath: String? = nil
|
||||
) -> String {
|
||||
// byName resolves only when the product name matches the package
|
||||
// name (`Lyrebird`). Sibling products (`LyrebirdUI`) need the
|
||||
@@ -374,12 +418,12 @@ public enum ProjectScaffolder {
|
||||
targetDeps = #""Lyrebird""#
|
||||
case .uiDemo:
|
||||
targetDeps = #""Lyrebird", .product(name: "LyrebirdUI", package: "Lyrebird")"#
|
||||
case .macosUIXcode, .iosUI, .auv3:
|
||||
case .shoegaze, .macosUIXcode, .iosUI, .auv3, .shoegazeIOS:
|
||||
// Xcode-bearing templates don't emit a `Package.swift` — dispatch
|
||||
// never reaches this function for them. Defensive fallthrough.
|
||||
targetDeps = #""Lyrebird", .product(name: "LyrebirdUI", package: "Lyrebird")"#
|
||||
}
|
||||
let depLine: String
|
||||
let lyrebirdDepLine: String
|
||||
if let path: String = lyrebirdPath {
|
||||
// `name:` is required so byName target deps (e.g. `"Lyrebird"`)
|
||||
// resolve — SPM otherwise uses the directory basename as the
|
||||
@@ -388,10 +432,13 @@ public enum ProjectScaffolder {
|
||||
// Path escaped for safe embedding in a Swift string literal —
|
||||
// same `\\` then `"` escape semantics as `pbxQuoteEscape`.
|
||||
let escapedPath: String = pbxQuoteEscape(path)
|
||||
depLine = #".package(name: "Lyrebird", path: "\#(escapedPath)"),"#
|
||||
lyrebirdDepLine = #".package(name: "Lyrebird", path: "\#(escapedPath)"),"#
|
||||
} else {
|
||||
depLine = #".package(url: "\#(lyrebirdPackageURL)", from: "\#(lyrebirdMinimumVersion)"),"#
|
||||
lyrebirdDepLine = #".package(url: "\#(lyrebirdPackageURL)", from: "\#(lyrebirdMinimumVersion)"),"#
|
||||
}
|
||||
|
||||
let dependenciesBlock: String = lyrebirdDepLine
|
||||
|
||||
return """
|
||||
// swift-tools-version: 6.0
|
||||
import PackageDescription
|
||||
@@ -400,7 +447,7 @@ public enum ProjectScaffolder {
|
||||
name: "\(name)",
|
||||
platforms: [.macOS(.v15)],
|
||||
dependencies: [
|
||||
\(depLine)
|
||||
\(dependenciesBlock)
|
||||
],
|
||||
targets: [
|
||||
.executableTarget(
|
||||
@@ -424,12 +471,12 @@ public enum ProjectScaffolder {
|
||||
template: ProjectTemplate = .basic
|
||||
) -> String {
|
||||
switch template {
|
||||
case .basic: return mainSwiftBasic(name: name)
|
||||
case .demo: return mainSwiftDemo(name: name)
|
||||
case .uiDemo: return mainSwiftUIDemo(name: name)
|
||||
case .nrt: return mainSwiftNRT(name: name)
|
||||
case .score: return mainSwiftScore(name: name)
|
||||
case .macosUIXcode, .iosUI, .auv3:
|
||||
case .basic: return mainSwiftBasic(name: name)
|
||||
case .demo: return mainSwiftDemo(name: name)
|
||||
case .uiDemo: return mainSwiftUIDemo(name: name)
|
||||
case .nrt: return mainSwiftNRT(name: name)
|
||||
case .score: return mainSwiftScore(name: name)
|
||||
case .shoegaze, .macosUIXcode, .iosUI, .auv3, .shoegazeIOS:
|
||||
// Xcode-bearing templates don't emit a `main.swift` under
|
||||
// `Sources/<name>/`. Dispatch never reaches this function for
|
||||
// them. Defensive fallthrough to the basic skeleton.
|
||||
@@ -759,6 +806,98 @@ public enum ProjectScaffolder {
|
||||
"""
|
||||
}
|
||||
|
||||
// MARK: shoegaze
|
||||
|
||||
private static func mainSwiftShoegaze(name: String) -> String {
|
||||
"""
|
||||
// \(name) — ShoeGaze guitar pedalboard
|
||||
import AppKit
|
||||
|
||||
// Program entry runs on the main thread; assert main-actor isolation for the
|
||||
// AppKit bootstrap rather than hopping asynchronously.
|
||||
MainActor.assumeIsolated {
|
||||
let app: NSApplication = NSApplication.shared
|
||||
let delegate: AppDelegate = AppDelegate()
|
||||
app.setActivationPolicy(.regular)
|
||||
app.delegate = delegate
|
||||
app.activate(ignoringOtherApps: true)
|
||||
app.run()
|
||||
}
|
||||
"""
|
||||
}
|
||||
|
||||
/// `AppDelegate.swift` content for a shoegaze project.
|
||||
public static func shoegazeAppDelegateSwift(name: String) -> String {
|
||||
let blockSize: Int = scaffoldDefaultBlockSize
|
||||
let sampleRate: Double = 48_000.0
|
||||
let outputChannels: Int = scaffoldDefaultOutputChannels
|
||||
let inputChannels: Int = 0
|
||||
let windowWidth: Int = 980
|
||||
let windowHeight: Int = 520
|
||||
return """
|
||||
import AppKit
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
import LyrebirdShoeGaze
|
||||
import LyrebirdShoeGazeUI
|
||||
|
||||
/// Application delegate for \(name).
|
||||
///
|
||||
/// Builds a `SynthesisEngine`, a `ShoeGaze` manager, and a default board of
|
||||
/// four pedals (Overdrive → Delay → Reverb → Modulation) fed by the built-in
|
||||
/// test loop, then opens a `LyrebirdWindow` hosting `ShoeGazeView`.
|
||||
@MainActor
|
||||
final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
private let engine: SynthesisEngine
|
||||
private let shoeGaze: ShoeGaze
|
||||
private let window: LyrebirdWindow
|
||||
|
||||
override init() {
|
||||
let engine: SynthesisEngine = SynthesisEngine(
|
||||
blockSize: \(blockSize),
|
||||
sampleRate: \(sampleRate),
|
||||
numOutputChannels: \(outputChannels),
|
||||
numInputChannels: \(inputChannels),
|
||||
driver: CoreAudioDriver()
|
||||
)
|
||||
self.engine = engine
|
||||
self.shoeGaze = ShoeGaze(engine: engine)
|
||||
self.window = LyrebirdWindow(
|
||||
title: "\(name)",
|
||||
width: \(windowWidth),
|
||||
height: \(windowHeight)
|
||||
)
|
||||
super.init()
|
||||
}
|
||||
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
do {
|
||||
let board: PedalBoard = try shoeGaze.addBoard()
|
||||
try board.add(OverdrivePedal())
|
||||
try board.add(DelayPedal())
|
||||
try board.add(ReverbPedal())
|
||||
try board.add(ModulationPedal())
|
||||
try shoeGaze.finalizeBoard(board)
|
||||
} catch {
|
||||
print("[\(name)] board build failed: \\(error)")
|
||||
}
|
||||
window.open {
|
||||
ShoeGazeView(shoeGaze: shoeGaze)
|
||||
}
|
||||
}
|
||||
|
||||
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||
true
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ notification: Notification) {
|
||||
engine.stop()
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
|
||||
// MARK: - ui-demo additional files
|
||||
|
||||
/// `AppDelegate.swift` content for a ui-demo project.
|
||||
|
||||
Reference in New Issue
Block a user