Skip to content
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

<ExternalDependency> is not a valid configured external dependency #6272

Open
sovata8 opened this issue May 10, 2024 · 2 comments
Open

<ExternalDependency> is not a valid configured external dependency #6272

sovata8 opened this issue May 10, 2024 · 2 comments
Labels
type:need/problem Report needs or problems you came across that are not bugs

Comments

@sovata8
Copy link

sovata8 commented May 10, 2024

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 sovata8 added the type:need/problem Report needs or problems you came across that are not bugs label May 10, 2024
@fortmarek
Copy link
Member

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

@sovata8
Copy link
Author

sovata8 commented May 15, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:need/problem Report needs or problems you came across that are not bugs
Projects
None yet
Development

No branches or pull requests

3 participants