-
-
Notifications
You must be signed in to change notification settings - Fork 727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSQLite must be imported by all SPM targets which transitively import GRDB #1424
Comments
Hi @mrackwitz :-) I started seeing the After a big refactoring of the project organization, we no longer see it. And of course I'm not sure of the exact reason. So I'll describe the project setup, in case this could help. ➡️ It is an Xcode project with a few targets that feed from an SPM package that contains several targets and libraries. ➡️ The SPM package is local: it belongs to the same git repository as the Xcode project. ➡️ The SPM package is not declared in the Xcode Project > Package Dependencies panel. I dragged it into the Project Navigator. ➡️ GRDB is not declared in the Xcode Project > Package Dependencies panel. It is not included in the linked libraries of the Xcode project targets. ➡️ GRDB is only declared as a dependency of the SPM package. ➡️ In the SPM package, all targets that have GRDB as a dependency export it as well. We currently have only one such target. Verification: Packages/MyPackage$ # Which targets import GRDB?
Packages/MyPackage$ git grep 'import GRDB$' | cut -f 1-2 -d / | uniq
Sources/HostPersistence
Packages/MyPackage$ # Which targets export GRDB?
Packages/MyPackage$ git grep '@_exported import GRDB$'
Sources/HostPersistence/_exported.swift:@_exported import GRDB Package.swift: let package = Package(
products: [
...
.library(name: "HostPersistence", targets: ["HostPersistence"]),
],
dependencies: [
...
.package(url: "https://github.com/groue/GRDB.swift.git", from: "6.20.1"),
],
targets: [
...
.target(
name: "HostPersistence",
dependencies: [
...
.product(name: "GRDB", package: "GRDB.swift"),
]
),
]
) I'll add here other relevant setup if I think about them or if someone asks a question. Everything is this setup looks "classic", but the If you can verify this hypothesis, and it works, then my advice for fixing the
Now I will explain why we export GRDB instead of strictly hiding it in the targets that depend on it. Of course, this can be considered controversial 😉 So let's see what we gain, and what we do not lose, when GRDB is exported.
Breakdown:
|
It is not relevant to keep this issue opened, since nobody is actually working on it. I'll repeat my latest advice:
And if anyone has a better idea, please chime in. |
What did you do?
Depend on GRDB in SPM target
Foo
, use said target in another SPM targetBar
, which is not using GRDB directly.What did you expect to happen?
The build to succeed without having to import transitive imports directly.
What happened instead?
SPM gives me a lot of errors:
Workaround
It's possible to workaround this for now by adding CSQLite as an explicit dependency to all targets that transitively depend on GRDB. (A lot in our case... 😉)
The text was updated successfully, but these errors were encountered: