Static consumer product + internal dynamic for LiveCompile
The Lyrebird product was forced type: .dynamic, forcing an SPM dynamic framework on consumers and hitting the Xcode 26 regression (PackageFrameworks/Lyrebird.framework binary missing). Split into two products vending the same LyrebirdSynth target: • Lyrebird (automatic → static): consumer-facing, no framework, no workarounds. • LyrebirdDynamic (.dynamic): internal-only, consumed by LiveCompile. LiveCompile repointed to LyrebirdDynamic with linker refs updated (libLyrebirdDynamic.dylib). README + GettingStarted updated: consumers link static and need no disable-library-validation entitlement or driver override. Verified: core + LiveCompile (34/34) build/test clean; external consumer links the static product with no dynamic dylib. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
|||||||
|
.build/
|
||||||
|
.claude/settings.local.json
|
||||||
|
.claude/worktrees/
|
||||||
|
*.o
|
||||||
|
*.d
|
||||||
|
*.swp
|
||||||
|
.DS_Store
|
||||||
|
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||||
|
xcuserdata/
|
||||||
|
*.xcuserstate
|
||||||
@@ -37,7 +37,7 @@ let package = Package(
|
|||||||
.target(
|
.target(
|
||||||
name: "LyrebirdLiveCompile",
|
name: "LyrebirdLiveCompile",
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.product(name: "Lyrebird", package: "Lyrebird"),
|
.product(name: "LyrebirdDynamic", package: "Lyrebird"),
|
||||||
],
|
],
|
||||||
path: "Sources/LyrebirdLiveCompile"
|
path: "Sources/LyrebirdLiveCompile"
|
||||||
),
|
),
|
||||||
@@ -45,7 +45,7 @@ let package = Package(
|
|||||||
name: "LyrebirdLiveCompileUI",
|
name: "LyrebirdLiveCompileUI",
|
||||||
dependencies: [
|
dependencies: [
|
||||||
"LyrebirdLiveCompile",
|
"LyrebirdLiveCompile",
|
||||||
.product(name: "Lyrebird", package: "Lyrebird"),
|
.product(name: "LyrebirdDynamic", package: "Lyrebird"),
|
||||||
],
|
],
|
||||||
path: "Sources/LyrebirdLiveCompileUI",
|
path: "Sources/LyrebirdLiveCompileUI",
|
||||||
swiftSettings: [.swiftLanguageMode(.v5)]
|
swiftSettings: [.swiftLanguageMode(.v5)]
|
||||||
@@ -54,7 +54,7 @@ let package = Package(
|
|||||||
name: "LyrebirdLiveCompileTests",
|
name: "LyrebirdLiveCompileTests",
|
||||||
dependencies: [
|
dependencies: [
|
||||||
"LyrebirdLiveCompile",
|
"LyrebirdLiveCompile",
|
||||||
.product(name: "Lyrebird", package: "Lyrebird"),
|
.product(name: "LyrebirdDynamic", package: "Lyrebird"),
|
||||||
],
|
],
|
||||||
path: "Tests/LyrebirdLiveCompileTests"
|
path: "Tests/LyrebirdLiveCompileTests"
|
||||||
),
|
),
|
||||||
@@ -63,7 +63,7 @@ let package = Package(
|
|||||||
dependencies: [
|
dependencies: [
|
||||||
"LyrebirdLiveCompile",
|
"LyrebirdLiveCompile",
|
||||||
"LyrebirdLiveCompileUI",
|
"LyrebirdLiveCompileUI",
|
||||||
.product(name: "Lyrebird", package: "Lyrebird"),
|
.product(name: "LyrebirdDynamic", package: "Lyrebird"),
|
||||||
],
|
],
|
||||||
path: "Tests/LyrebirdLiveCompileUITests",
|
path: "Tests/LyrebirdLiveCompileUITests",
|
||||||
swiftSettings: [.swiftLanguageMode(.v5)]
|
swiftSettings: [.swiftLanguageMode(.v5)]
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public final class LiveSession {
|
|||||||
public let libraries: [String]
|
public let libraries: [String]
|
||||||
|
|
||||||
/// `-Xlinker -rpath -Xlinker <path>` entries baked into the snippet dylib
|
/// `-Xlinker -rpath -Xlinker <path>` entries baked into the snippet dylib
|
||||||
/// so `dlopen` resolves dependent dylibs (`libLyrebird.dylib` etc.) at
|
/// so `dlopen` resolves dependent dylibs (`libLyrebirdDynamic.dylib` etc.) at
|
||||||
/// runtime without `DYLD_LIBRARY_PATH` ceremony.
|
/// runtime without `DYLD_LIBRARY_PATH` ceremony.
|
||||||
public let rpaths: [URL]
|
public let rpaths: [URL]
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ public final class LiveSession {
|
|||||||
engine: SynthesisEngine,
|
engine: SynthesisEngine,
|
||||||
importPaths: [URL] = LiveSession.defaultImportPaths(),
|
importPaths: [URL] = LiveSession.defaultImportPaths(),
|
||||||
librarySearchPaths: [URL] = LiveSession.defaultLibrarySearchPaths(),
|
librarySearchPaths: [URL] = LiveSession.defaultLibrarySearchPaths(),
|
||||||
libraries: [String] = ["Lyrebird", "LyrebirdLiveCompile"],
|
libraries: [String] = ["LyrebirdDynamic", "LyrebirdLiveCompile"],
|
||||||
rpaths: [URL] = LiveSession.defaultRpaths()
|
rpaths: [URL] = LiveSession.defaultRpaths()
|
||||||
) {
|
) {
|
||||||
self.engine = engine
|
self.engine = engine
|
||||||
@@ -257,7 +257,7 @@ public final class LiveSession {
|
|||||||
// MARK: - Build-dir discovery
|
// MARK: - Build-dir discovery
|
||||||
|
|
||||||
/// Best-effort discovery of the SPM `.build/<triple>/<config>` directory
|
/// Best-effort discovery of the SPM `.build/<triple>/<config>` directory
|
||||||
/// that contains `libLyrebird.dylib` and the swiftmodule directories. Used
|
/// that contains `libLyrebirdDynamic.dylib` and the swiftmodule directories. Used
|
||||||
/// as the default for `importPaths`/`librarySearchPaths`/`rpaths`. Hosts can
|
/// as the default for `importPaths`/`librarySearchPaths`/`rpaths`. Hosts can
|
||||||
/// override by passing explicit URLs.
|
/// override by passing explicit URLs.
|
||||||
///
|
///
|
||||||
@@ -277,9 +277,11 @@ public final class LiveSession {
|
|||||||
// LyrebirdSynth.swiftmodule (Xcode SPM static-linked into the host app).
|
// LyrebirdSynth.swiftmodule (Xcode SPM static-linked into the host app).
|
||||||
// The swiftmodule alone is enough for `-I` module resolution; linking
|
// The swiftmodule alone is enough for `-I` module resolution; linking
|
||||||
// falls back to `-undefined dynamic_lookup` when no dylib is found.
|
// falls back to `-undefined dynamic_lookup` when no dylib is found.
|
||||||
// Note: the product/dylib is named `Lyrebird` (libLyrebird.dylib); the
|
// Note: LiveCompile depends on the internal `LyrebirdDynamic` product
|
||||||
// module/target is named `LyrebirdSynth` (LyrebirdSynth.swiftmodule).
|
// (→ libLyrebirdDynamic.dylib); the module/target is `LyrebirdSynth`
|
||||||
let markers: [String] = ["libLyrebird.dylib", "LyrebirdSynth.swiftmodule"]
|
// (LyrebirdSynth.swiftmodule). The consumer-facing `Lyrebird` product
|
||||||
|
// is static and produces no dylib, so it is not a marker here.
|
||||||
|
let markers: [String] = ["libLyrebirdDynamic.dylib", "LyrebirdSynth.swiftmodule"]
|
||||||
for start: URL in candidates {
|
for start: URL in candidates {
|
||||||
var cur: URL = start
|
var cur: URL = start
|
||||||
for _ in 0..<maxWalk {
|
for _ in 0..<maxWalk {
|
||||||
@@ -297,13 +299,13 @@ public final class LiveSession {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `true` when a `libLyrebird.dylib` actually exists in `buildDir`. Used to
|
/// `true` when a `libLyrebirdDynamic.dylib` actually exists in `buildDir`.
|
||||||
/// decide whether to link against the dylib at compile time or fall back to
|
/// Used to decide whether to link against the dylib at compile time or fall
|
||||||
/// `-undefined dynamic_lookup` so the snippet binds to symbols already
|
/// back to `-undefined dynamic_lookup` so the snippet binds to symbols
|
||||||
/// resolved in the running process.
|
/// already resolved in the running process.
|
||||||
public static func hasLyrebirdDylib(in buildDir: URL) -> Bool {
|
public static func hasLyrebirdDylib(in buildDir: URL) -> Bool {
|
||||||
FileManager.default.fileExists(
|
FileManager.default.fileExists(
|
||||||
atPath: buildDir.appendingPathComponent("libLyrebird.dylib").path
|
atPath: buildDir.appendingPathComponent("libLyrebirdDynamic.dylib").path
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ struct LiveSessionTests {
|
|||||||
@Test
|
@Test
|
||||||
func buildDirDiscoveryFindsLyrebirdDylib() throws {
|
func buildDirDiscoveryFindsLyrebirdDylib() throws {
|
||||||
let buildDir: URL = try #require(LiveSession.currentBuildDir())
|
let buildDir: URL = try #require(LiveSession.currentBuildDir())
|
||||||
let dylib: URL = buildDir.appendingPathComponent("libLyrebird.dylib")
|
let dylib: URL = buildDir.appendingPathComponent("libLyrebirdDynamic.dylib")
|
||||||
#expect(FileManager.default.fileExists(atPath: dylib.path))
|
#expect(FileManager.default.fileExists(atPath: dylib.path))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+23
-14
@@ -5,14 +5,22 @@ let package = Package(
|
|||||||
name: "Lyrebird",
|
name: "Lyrebird",
|
||||||
platforms: [.macOS(.v15), .iOS(.v18)],
|
platforms: [.macOS(.v15), .iOS(.v18)],
|
||||||
products: [
|
products: [
|
||||||
// Product name stays `Lyrebird` (external API), but it vends the
|
// Consumer-facing product. Automatic linkage → SwiftPM/Xcode link the
|
||||||
// renamed `LyrebirdSynth` target/module. Product name ≠ target name is
|
// `LyrebirdSynth` module statically into the downstream target. No
|
||||||
// required: a forced-`.dynamic` product cannot share a name with its
|
// dynamic framework is produced, so the Xcode 26 regression where the
|
||||||
// target when a downstream project's graph also static-links that
|
// `PackageFrameworks/Lyrebird.framework` binary is never built (and the
|
||||||
// target ("linked as a static library … but cannot be built
|
// app fails to link / launch) cannot affect external consumers.
|
||||||
// dynamically because there is a package product with the same name").
|
// Product name ≠ target name (`Lyrebird` vends `LyrebirdSynth`) so there
|
||||||
// Consumers add the `Lyrebird` product and write `import LyrebirdSynth`.
|
// is also no static-vs-dynamic same-name collision. Consumers add the
|
||||||
.library(name: "Lyrebird", type: .dynamic, targets: ["LyrebirdSynth"]),
|
// `Lyrebird` product and write `import LyrebirdSynth`.
|
||||||
|
.library(name: "Lyrebird", targets: ["LyrebirdSynth"]),
|
||||||
|
// Internal-only DYNAMIC product — consumed solely by the nested
|
||||||
|
// `LiveCompile/` dev sub-package. LiveCompile needs a single shared
|
||||||
|
// `libLyrebirdDynamic.dylib` on disk so the host and each live-compiled
|
||||||
|
// snippet dylib resolve to ONE copy of every Lyrebird class (the ObjC
|
||||||
|
// double-registration crash fixed in Phase 167). External consumers
|
||||||
|
// never reference this product — they use `Lyrebird` (static) above.
|
||||||
|
.library(name: "LyrebirdDynamic", type: .dynamic, targets: ["LyrebirdSynth"]),
|
||||||
.library(name: "LyrebirdUI", targets: ["LyrebirdUI"]),
|
.library(name: "LyrebirdUI", targets: ["LyrebirdUI"]),
|
||||||
.executable(name: "LyrebirdCLI", targets: ["LyrebirdCLI"]),
|
.executable(name: "LyrebirdCLI", targets: ["LyrebirdCLI"]),
|
||||||
],
|
],
|
||||||
@@ -94,12 +102,13 @@ let package = Package(
|
|||||||
),
|
),
|
||||||
// Phase 167 — `LyrebirdLiveCompile` (and its SwiftUI host
|
// Phase 167 — `LyrebirdLiveCompile` (and its SwiftUI host
|
||||||
// `LyrebirdLiveCompileUI`) moved to the `LiveCompile/` nested SwiftPM
|
// `LyrebirdLiveCompileUI`) moved to the `LiveCompile/` nested SwiftPM
|
||||||
// package. The cross-package `.product(name: "Lyrebird", package: "Lyrebird")`
|
// package. It depends on the internal `.product(name: "LyrebirdDynamic",
|
||||||
// dependency there forces SwiftPM to dynamic-link the live-compile dylib
|
// package: "Lyrebird")` (the dynamic product above) so SwiftPM
|
||||||
// against `libLyrebird.dylib` instead of statically embedding the core
|
// dynamic-links the live-compile dylib against `libLyrebirdDynamic.dylib`
|
||||||
// module's classes, which was the root cause of an ObjC class
|
// instead of statically embedding the core module's classes — the root
|
||||||
// double-registration crash during `swift test` in the single-package
|
// cause of an ObjC class double-registration crash during `swift test`
|
||||||
// layout. See `LiveCompile/Package.swift`.
|
// in the single-package layout. The consumer-facing `Lyrebird` product
|
||||||
|
// stays static (see products list). See `LiveCompile/Package.swift`.
|
||||||
.executableTarget(
|
.executableTarget(
|
||||||
name: "LyrebirdBenchmark",
|
name: "LyrebirdBenchmark",
|
||||||
dependencies: ["LyrebirdSynth"],
|
dependencies: ["LyrebirdSynth"],
|
||||||
|
|||||||
@@ -141,18 +141,9 @@ Add the package:
|
|||||||
https://realizedsound.mooo.com/josh/Lyrebird.git
|
https://realizedsound.mooo.com/josh/Lyrebird.git
|
||||||
```
|
```
|
||||||
|
|
||||||
**File ▸ Add Package Dependencies…** → that URL → **Up to Next Major** from `1.0.0` → add the `Lyrebird` product (and `LyrebirdUI` for the SwiftUI controls).
|
**File ▸ Add Package Dependencies…** → that URL → **Up to Next Major** from `1.0.0` → add the `Lyrebird` product (and `LyrebirdUI` for the SwiftUI controls). Write `import LyrebirdSynth` in your code (the product is `Lyrebird`; the module it vends is `LyrebirdSynth`).
|
||||||
|
|
||||||
Then three settings a hand-made project needs (the `lyrebird new` scaffolds set all three for you):
|
That's it — the `Lyrebird` product links **statically**, so there's no dynamic framework, no embed step, and **no special build settings**: you do *not* need a `disable-library-validation` entitlement or a `SWIFT_USE_INTEGRATED_DRIVER` override. It just links, even under Hardened Runtime / sandbox / AUv3.
|
||||||
|
|
||||||
1. **Embed the framework.** App targets: confirm Lyrebird shows under *General ▸ Frameworks, Libraries, and Embedded Content* as **Embed & Sign** (Xcode sets this automatically). CLI/SwiftPM executables need no embed.
|
|
||||||
2. **Disable library validation** — required for any target with **Hardened Runtime** (signed apps + all AUv3). `Lyrebird` ships as a `.dynamic` library; its SPM-built `libLyrebird.dylib` is ad-hoc-signed, so dyld otherwise fails with `dyld: Library not loaded`. Add to the target's `.entitlements`, then clean build (⇧⌘K):
|
|
||||||
```xml
|
|
||||||
<key>com.apple.security.cs.disable-library-validation</key>
|
|
||||||
<true/>
|
|
||||||
```
|
|
||||||
Plain debug apps without Hardened Runtime can skip this.
|
|
||||||
3. **Xcode 26 Swift-driver workaround** (only if the build throws Swift driver errors): set `SWIFT_USE_INTEGRATED_DRIVER = NO` and `parallelizeBuildables = NO` in Build Settings.
|
|
||||||
|
|
||||||
Full walk-through (SPM manifest form, local-path dev dependency, per-template details): [`INSTALLATION_AND_USAGE.md`](INSTALLATION_AND_USAGE.md). DocC version: **Getting Started ▸ Adding Lyrebird to your own Xcode project**.
|
Full walk-through (SPM manifest form, local-path dev dependency, per-template details): [`INSTALLATION_AND_USAGE.md`](INSTALLATION_AND_USAGE.md). DocC version: **Getting Started ▸ Adding Lyrebird to your own Xcode project**.
|
||||||
|
|
||||||
@@ -193,8 +184,8 @@ Use `Lyrebird-Package` for day-to-day development of the engine and tests.
|
|||||||
| `Synchronization.Atomic` not indexed | Requires Xcode 16+ — false errors in older versions, still builds |
|
| `Synchronization.Atomic` not indexed | Requires Xcode 16+ — false errors in older versions, still builds |
|
||||||
| LineNoise concurrency warnings | Expected — `LyrebirdCLI` uses `.swiftLanguageMode(.v5)` intentionally |
|
| LineNoise concurrency warnings | Expected — `LyrebirdCLI` uses `.swiftLanguageMode(.v5)` intentionally |
|
||||||
| Nimble in Package dependencies | Cosmetic — LineNoise transitive dep, never built in Lyrebird targets |
|
| Nimble in Package dependencies | Cosmetic — LineNoise transitive dep, never built in Lyrebird targets |
|
||||||
| Build fails with Swift driver errors | Xcode 26 bug — workspace already sets `SWIFT_USE_INTEGRATED_DRIVER = NO`, `parallelizeBuildables = NO`, `type: .dynamic`. In your own project see [Adding Lyrebird to your own project](#adding-lyrebird-to-your-own-project) |
|
| Build fails with Swift driver errors | Xcode 26 bug affecting the **demo workspace** (which dynamic-links for live-coding) — it already sets `SWIFT_USE_INTEGRATED_DRIVER = NO` + `parallelizeBuildables = NO`. Your own project links Lyrebird statically and is unaffected. |
|
||||||
| `dyld: Library not loaded` | Hardened Runtime rejects the ad-hoc-signed SPM framework — add `com.apple.security.cs.disable-library-validation = true` to entitlements, then clean build (⇧⌘K). Full steps: [Adding Lyrebird to your own project](#adding-lyrebird-to-your-own-project) |
|
| `dyld: Library not loaded` | Only the bundled demos/AUv3 use the dynamic `LyrebirdDynamic` product; their entitlements already set `disable-library-validation`. External consumers link the static `Lyrebird` product and never hit this. |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -165,12 +165,8 @@ Writes a starter ``SynthesizerBase`` subclass into your project.
|
|||||||
|
|
||||||
## Adding Lyrebird to your own Xcode project
|
## Adding Lyrebird to your own Xcode project
|
||||||
|
|
||||||
If you're not using the scaffolder — adding Lyrebird as a dependency of an
|
Adding Lyrebird as a dependency of an existing or hand-made Xcode project is a
|
||||||
existing or hand-made Xcode project — there are three settings to know. The
|
single step — no special build settings required.
|
||||||
generated templates set these for you; a hand-made project needs them applied
|
|
||||||
manually.
|
|
||||||
|
|
||||||
### 1. Add the package and product
|
|
||||||
|
|
||||||
**File ▸ Add Package Dependencies…**, enter the repository URL:
|
**File ▸ Add Package Dependencies…**, enter the repository URL:
|
||||||
|
|
||||||
@@ -179,47 +175,25 @@ https://realizedsound.mooo.com/josh/Lyrebird.git
|
|||||||
```
|
```
|
||||||
|
|
||||||
Choose **Up to Next Major Version** from `1.0.0`, then add the `Lyrebird`
|
Choose **Up to Next Major Version** from `1.0.0`, then add the `Lyrebird`
|
||||||
product (and `LyrebirdUI` if you use the SwiftUI controls) to your target.
|
product (and `LyrebirdUI` if you use the SwiftUI controls) to your target. In
|
||||||
|
your source write `import LyrebirdSynth` — the *product* is named `Lyrebird`,
|
||||||
|
the *module* it vends is `LyrebirdSynth`.
|
||||||
|
|
||||||
For an **app** target, confirm Lyrebird appears under **General ▸ Frameworks,
|
The `Lyrebird` product uses **automatic linkage**, so SwiftPM/Xcode link it
|
||||||
Libraries, and Embedded Content** with **Embed & Sign** selected — Xcode sets
|
**statically** into your target. There is no dynamic framework to embed and no
|
||||||
this automatically for apps. A plain command-line / SwiftPM executable target
|
ad-hoc-signed dylib to load, which means:
|
||||||
needs no embed step.
|
|
||||||
|
|
||||||
### 2. Hardened Runtime → disable library validation
|
- **No** `com.apple.security.cs.disable-library-validation` entitlement.
|
||||||
|
- **No** `SWIFT_USE_INTEGRATED_DRIVER` / `parallelizeBuildables` override.
|
||||||
|
- Works as-is under Hardened Runtime, App Sandbox, and AUv3.
|
||||||
|
|
||||||
`Lyrebird` is built as a **dynamic** library (`type: .dynamic` in its
|
> The package also vends an internal `LyrebirdDynamic` (`type: .dynamic`)
|
||||||
`Package.swift` — a deliberate workaround for an Xcode 26 SwiftPM regression,
|
> product used **only** by the bundled `LiveCompile/` live-coding sub-package
|
||||||
reverting to `.static` once fixed). The SwiftPM-built `libLyrebird.dylib` is
|
> (it needs a shared dylib so live-compiled snippets and the host resolve to one
|
||||||
ad-hoc-signed, not signed by your team. Any target with **Hardened Runtime**
|
> copy of every class). External consumers never reference `LyrebirdDynamic`.
|
||||||
enabled — every signed/notarized app, and **all** AUv3 extensions — will
|
> The demo workspace and AUv3 sample link that dynamic product, which is why
|
||||||
otherwise fail at launch with:
|
> *those* projects carry the `disable-library-validation` entitlement and the
|
||||||
|
> Xcode-26 driver settings — your own project does not.
|
||||||
```
|
|
||||||
dyld: Library not loaded: @rpath/libLyrebird.dylib
|
|
||||||
```
|
|
||||||
|
|
||||||
Fix: add this key to the target's `.entitlements`, then clean build (⇧⌘K):
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<key>com.apple.security.cs.disable-library-validation</key>
|
|
||||||
<true/>
|
|
||||||
```
|
|
||||||
|
|
||||||
A plain debug app **without** Hardened Runtime doesn't need this — skip it.
|
|
||||||
|
|
||||||
### 3. Xcode 26 Swift-driver workaround
|
|
||||||
|
|
||||||
If the build fails with Swift driver errors, set in **Build Settings**:
|
|
||||||
|
|
||||||
- `SWIFT_USE_INTEGRATED_DRIVER = NO`
|
|
||||||
- `parallelizeBuildables = NO`
|
|
||||||
|
|
||||||
Both are temporary, tied to the same Xcode 26 regression as the dynamic-library
|
|
||||||
choice.
|
|
||||||
|
|
||||||
> The `lyrebird new --template macos-ui-xcode | ios-ui | auv3` scaffolds apply
|
|
||||||
> all three automatically. Reach for them if you'd rather not wire this by hand.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user