<ExternalDependency> is not a valid configured external dependency
What problem or need do you have?
I am trying to get a very basic setup running, but getting an error generating the project.
I have an app, depending on a local Swift Package, which itself depends on a remote (external) package.
I followed the docs: https://docs.tuist.io/guide/project/dependencies
Ideally I'd like the 'XcodeProj-based integration' approach.
MyApp (a SwiiftUI app) |____ MyUI (A local Swift Package - added as a local dependency to MyApp) |____ SnapKit (A third-party package hosted on GitHub - added as an external dependency (GitHub) to MyUI)]
- When generating just the
MyUITuist project, it works fine. - When generating the
MyAppTuist project, I get error:'SnapKit' is not a valid configured external dependency. - If I remove the dependency on
SnapKit, I can generateMyAppsuccessfully.
I tried with other frameworks too, not only SnapKit (like Alamofire, DeepDiff, SDWebImage)
MyApp has Project.swift:
let project = Project(
name: "MyTuistApp",
targets: [
.target(
name: "MyTuistApp",
destinations: .iOS,
product: .app,
sources: ["MyTuistApp/Sources/**"],
dependencies: [
.project(target: "MyUI", path: "./Packages/MyUI"),
]
),
]
)
MyApp has Project.swift:
let project = Project(
name: "MyUI",
targets: [
.target(
name: "MyUI",
destinations: .iOS,
product: .framework,
sources: ["Sources/**"],
dependencies: [
.external(name: "SnapKit")
]
)
]
)
and Package.swift:
let package = Package(
name: "MyUI",
dependencies: [
.package(url: "https://github.com/SnapKit/SnapKit", from: "5.0.1")
]
)
Any info would be appreciated, thanks
Potential solution
No response
macOS version
14.1.1
Tuist version
4.9.0
Xcode version
15.2
Hey @sovata8 👋
Can you post a reproducible project that you worked with? Have you run tuist install after adding the dependency in your Tuist/Package.swift?
You can check out our fixture that showcases how to integrate dependencies via the XcodeProj-based integration: https://github.com/tuist/tuist/tree/main/fixtures/app_with_spm_dependencies
Hi, thanks for the reply.
The link to the sample project was a great resource! I took it and reduced it to exactly my reproducible case, and can now observe where things fail.
I am attaching both my sample minimal reproducible project, and the modified Tuist's app_with_spm_dependencies.
tl;dr: Things work only if the Alamofire package is defined under MyApp's Package.swift - if we define it in MyFramework's Package.swift, tuist-generate only works from the framework's folder, but fails for the whole app. Provided only MyFramework needs to know about the external dependency, ideally we'd like to define the it under MyFramwork, not globally.
The findings
(The explanation here applies to both attached projects, they have been reduced to the same reproducible issue)
So, in both projects MyApp -> MyFramework -> Alamofire.
Both MyApp and MyFramework have a Project.swift.
MyApp does not depend on 'Alamofire' (directly) only on MyFramework.
(Note, this is different from the original app_with_spm_dependencies where both the App and FeatureOne depend directly on Alamofire)
MyFramework's 'Project.swift' has as a target dependency:
.project(target: "FeatureOneFramework_iOS", path: .relativeToRoot("Features/FeatureOne"))
MyFramework's 'Project.swift' has as a target dependency:
.external(name: "Alamofire")
When it works and when it doesn't
We need to define the Alamofire package somewhere:
.package(url: "https://github.com/Alamofire/Alamofire", exact: "5.8.0")
If we define it under MyApp/Tuist/Package.swift, things work perfectly - the project generates, builds and runs. Alamofire is only linked to MyFramework as it should. We can also generate and build just MyFramework's project from its own folder, which is great.
But the above is somewhat confusing / unexpected / not ideal - by defining he package in the main app's Tuist/Package.swift, we make a 'hidden' dependency of MyFramework on a Tuist package defined under MyApp. Indeed, if we take this framework folder and put it elsewhere on our filesystem, it won't tuist-generate anymore, because the URL for Alamofire was defined in MyApp.
Ideally, we would like to be able to define the Alamofire package under MyFramework/Tuist/Package.swift.
Doing this actually works fine when generating MyFramework only, from its folder.
But then if we switch to MyApp, the generation fails with:
``Alamofire is not a valid configured external dependency
Zip files
I'd like to bump this issue.
I encounter the same problem. My setup is similar, only all dependencies are local defined by path ../
Ran into this as well, for a Project inside a Workspace, which seems like it should be a rather common use case.
The project is part of the workspace, and is dependent on an external package defined in Workspace/Project/Tuist/Package.swift. Running tuist install then tuist generate from the Project directory - works well, but if you attempt to run it from the Workspace directory, there's a is not a valid configured external dependency message.
Same issue