tuist icon indicating copy to clipboard operation
tuist copied to clipboard

<ExternalDependency> is not a valid configured external dependency

Open sovata8 opened this issue 1 year ago • 5 comments

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 MyUI Tuist project, it works fine.
  • When generating the MyApp Tuist project, I get error: 'SnapKit' is not a valid configured external dependency.
  • If I remove the dependency on SnapKit, I can generate MyApp successfully.

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

sovata8 avatar May 10 '24 15:05 sovata8

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

fortmarek avatar May 13 '24 10:05 fortmarek

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

sovata8 avatar May 15 '24 08:05 sovata8

I'd like to bump this issue. I encounter the same problem. My setup is similar, only all dependencies are local defined by path ../

krzyzanowskim avatar Aug 13 '24 06:08 krzyzanowskim

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.

TamarMilchtaich avatar Sep 02 '24 13:09 TamarMilchtaich

Same issue

jesus-mg-ios avatar Sep 15 '24 16:09 jesus-mg-ios