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

Two packages with the same target name #6176

Open
Ernest0-Production opened this issue Apr 11, 2024 · 1 comment
Open

Two packages with the same target name #6176

Ernest0-Production opened this issue Apr 11, 2024 · 1 comment
Labels
type:bug Something isn't working

Comments

@Ernest0-Production
Copy link

Ernest0-Production commented Apr 11, 2024

What happened?

I have two almost identical SPM packages (for different platforms), with different product names.
But the targets in the products are the same.

// iOS Package Example
let package = Package(
    name: "Framework-iOS",
    platform: [.iOS(.v15)],
    products: [
        .library(
            name: "Framework-iOS",
            targets: [ 
                "FrameworkBinary"
            ]
        )
    ],
    targets: [ 
        .binaryTarget(
            name: "FrameworkBinary", // 👀
            path: "path/to/ios.xcframework"
        )
    ]
)
// TV os Example
let package = Package(
    name: "Framework-tvOS",
    platform: [.tvOS(.v15)],
    products: [
        .library(
            name: "Framework-tvOS",
            targets: [ 
                "FrameworkBinary"
            ]
        )
    ],
    targets: [ 
        .binaryTarget(
            name: "FrameworkBinary", // 👀
            path: "path/to/tvos.xcframework"
        )
    ]
)

If I add both packages to Tuist/Package.swift and connect iOS framework to my project target, there is a bug:

  • every time I run tuist generate, Tuist connects to my target either iOS.xcframework or tvOS.xcframework - randomly

Workaroung:

Rename the target names to "FrameworkiOSBinary" and "FrameworkTvOsBinary"

How do we reproduce it?

Repro in example ⬆️

Error log

I get an error when compiling the target, which indicates that an attempt is being made to link a framework from a platform other than the target

macOS version

14

Tuist version

4.9.0

Xcode version

15.2

@Ernest0-Production Ernest0-Production added the type:bug Something isn't working label Apr 11, 2024
@fortmarek
Copy link
Member

This is a valid bug. We turn all targets from Package.swift into .external without the package identifier which is not correct. This leads to issues like this when the names clash. We should imho extend the .external case to optionally include the package name and try to match that first.

Would you want to take a look at this? Most of the logic can be found in PackageInfoMapper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants