Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ let package = Package(
name: "CasePaths",
description: "Introduce support for enum tables."
),
.trait(
name: "GRDBDynamic",
description: "Link the GRDB-dynamic library instead of the static GRDB library."
),
.trait(
name: "SuppressPlatformSQLiteAvailability",
description: """
Expand Down Expand Up @@ -82,6 +86,11 @@ let package = Package(
.product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
.product(name: "Dependencies", package: "swift-dependencies"),
.product(name: "GRDB", package: "GRDB.swift"),
.product(
name: "GRDB-dynamic",
package: "GRDB.swift",
condition: .when(traits: ["GRDBDynamic"])
),
Comment on lines 88 to +93

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GRDB's README states:

GRDB offers two libraries, GRDB and GRDB-dynamic. Pick only one.

So I do wonder if this is legit to do or if it could lead to linking problems down the line. And I guess there's no way to negate a package condition 😕

We'll think on it, but I wonder if traits aren't the right tool here after all.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my current build tests, when the trait is enabled, SPM automatically picks GRDB-dynamic over GRDB. I’m not entirely sure how it makes that decision, but it does work for now.

That said, depending on both products at the same time does feel a bit odd, and can’t be sure this behavior won’t change later. A more reliable approach might be to expose two separate products and avoid using traits altogether.

.product(name: "IssueReporting", package: "xctest-dynamic-overlay"),
.product(name: "OrderedCollections", package: "swift-collections"),
.product(name: "Perception", package: "swift-perception"),
Expand Down