Files
Lyrebird/LiveCompile/Package.swift
T

84 lines
3.1 KiB
Swift

// Package.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
// swift-tools-version: 6.0
import PackageDescription
// `LyrebirdLiveCompile` and `LyrebirdLiveCompileUI` live in this
// sub-package so that cross-package `.product(name:, package:)` dependency
// resolution forces SwiftPM to dynamic-link `libLyrebirdLiveCompile.dylib`
// against `libLyrebird.dylib` instead of statically embedding `Lyrebird`'s
// classes (which caused ObjC class double-registration during `swift test`
// in the single-package layout).
//
// macOS-only — the host swiftc-shell-out + dlopen surface cannot run on iOS.
let package = Package(
name: "LyrebirdLiveCompile",
platforms: [.macOS(.v15)],
products: [
// Product name ≠ target name (mirrors the main package's
// `Lyrebird`/`LyrebirdDynamic` pairing). A `.dynamic` product whose name
// EQUALS its target name collides in Xcode when that target is also
// referenced as a static link elsewhere in the same build graph:
// "Swift package target 'X' is linked as a static library by … but
// cannot be built dynamically because there is a package product with
// the same name." Naming the dynamic products `…Dynamic` removes the
// collision so each target builds as a single shared dylib that every
// consumer links dynamically. Target/module names are unchanged, so
// `import LyrebirdLiveCompile` / `import LyrebirdLiveCompileUI` and the
// test targets (which reference targets by name) are unaffected.
.library(
name: "LyrebirdLiveCompileDynamic",
type: .dynamic,
targets: ["LyrebirdLiveCompile"]
),
.library(
name: "LyrebirdLiveCompileUIDynamic",
type: .dynamic,
targets: ["LyrebirdLiveCompileUI"]
),
],
dependencies: [
.package(name: "Lyrebird", path: "..")
],
targets: [
.target(
name: "LyrebirdLiveCompile",
dependencies: [
.product(name: "LyrebirdDynamic", package: "Lyrebird"),
],
path: "Sources/LyrebirdLiveCompile"
),
.target(
name: "LyrebirdLiveCompileUI",
dependencies: [
"LyrebirdLiveCompile",
.product(name: "LyrebirdDynamic", package: "Lyrebird"),
],
path: "Sources/LyrebirdLiveCompileUI"
// Swift 6 language mode: inherits the swift-tools 6.0 default.
),
.testTarget(
name: "LyrebirdLiveCompileTests",
dependencies: [
"LyrebirdLiveCompile",
.product(name: "LyrebirdDynamic", package: "Lyrebird"),
],
path: "Tests/LyrebirdLiveCompileTests"
),
.testTarget(
name: "LyrebirdLiveCompileUITests",
dependencies: [
"LyrebirdLiveCompile",
"LyrebirdLiveCompileUI",
.product(name: "LyrebirdDynamic", package: "Lyrebird"),
],
path: "Tests/LyrebirdLiveCompileUITests"
),
]
)