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

Detect targets with duplicate product name #6118

Open
fortmarek opened this issue Mar 26, 2024 · 3 comments · May be fixed by #6205
Open

Detect targets with duplicate product name #6118

fortmarek opened this issue Mar 26, 2024 · 3 comments · May be fixed by #6205
Labels
good first issue Good for newcomers type:need/problem Report needs or problems you came across that are not bugs

Comments

@fortmarek
Copy link
Member

fortmarek commented Mar 26, 2024

What problem or need do you have?

When a project has duplicate products, tuist cache fails with errors such as:

❌ error: Multiple commands produce '/var/folders/m2/w681m9fj2fx_wg7l_m38_bz00000gn/T/TemporaryDirectory.jrHZpX/derived-data/Build/Intermediates.noindex/ArchiveIntermediates/Binaries-Cache-iOS/InstallationBuildProductsLocation/Library/Frameworks/SomeModule.framework'

We should be able to detect this in a linter and send out a warning to make it more obvious.

You can find the example project attached here:

Project.swift example

import ProjectDescription

let marketingVersion = "1.0.0"
let currentProjectVersion = "0"
let deploymentTargets = DeploymentTargets.iOS("16.0")
let destinations: Destinations = [.iPhone]

let project = Project(
    name: "tuist-demo",
    organizationName: "com.cardinalblue",
    packages: [
        .remote(
            url: "https://github.com/pointfreeco/swift-composable-architecture",
            requirement: .upToNextMajor(from: "1.5.5")
        )
    ],
    targets: [
        Target.target(
            name: "tuist-demo",
            destinations: destinations,
            product: .app,
            productName: "tuist-demo",
            bundleId: "com.cardinalblue.tuistdemo.tuist-demo",
            deploymentTargets: deploymentTargets,
            infoPlist: .extendingDefault(
                with: [
                    "CFBundleShortVersionString": Plist.Value(stringLiteral: marketingVersion),
                    "UIStatusBarHidden": true,
                    "UILaunchScreen": [:],
                    "UISupportedInterfaceOrientations": ["UIInterfaceOrientationPortrait"]
                ]
            ),
            sources: "tuist-demo/**",
            entitlements: "tuist-demo/tuist_demo.entitlements",
            dependencies: [.package(product: "ComposableArchitecture", type: .runtime)],
            settings: .settings(
                base: [
                    "INFOPLIST_KEY_CFBundleDisplayName": "tuist-demo",
                    "MARKETING_VERSION": SettingValue(stringLiteral: marketingVersion),
                    "CURRENT_PROJECT_VERSION": SettingValue(stringLiteral: currentProjectVersion)
                ],
                configurations: []
            )
        ),
        Target.target(
            name: "SomeModule",
            destinations: destinations,
            product: .framework,
            productName: "SomeModule",
            bundleId: "com.cardinalblue.SomeModule",
            deploymentTargets: deploymentTargets,
            sources: "SomeModule/**",
            resources: ["SomeModule/SomeModule.h"]
        ),
        Target.target(
            name: "SomeModule2",
            destinations: destinations,
            product: .framework,
            productName: "SomeModule",
            bundleId: "com.cardinalblue.SomeModule2",
            deploymentTargets: deploymentTargets,
            sources: "SomeModule2/**",
            resources: ["SomeModule2/SomeModule2.h"]
        )
    ]
)

@fortmarek fortmarek added type:need/problem Report needs or problems you came across that are not bugs good first issue Good for newcomers labels Mar 26, 2024
@rsarv3006
Copy link
Contributor

I'm going to take a stab at fixing this unless someone else already has?

@kwridan
Copy link
Collaborator

kwridan commented Apr 16, 2024

Thanks @rsarv3006 and @fortmarek

Worth noting that having multiple targets with a common productName was a common way to support multi destinations prior to multi destination support. That of its own isn't an issue

e.g.

https://github.com/tuist/tuist/blob/main/fixtures/ios_app_with_headers/Framework1/Project.swift

Issues that may be worth raising are if two dependencies of a target have the same product name.

@rsarv3006
Copy link
Contributor

@kwridan Based on the example Project that Marek linked I believe the intention is to warn on dependencies with the same name.

@rsarv3006 rsarv3006 linked a pull request Apr 18, 2024 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type:need/problem Report needs or problems you came across that are not bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants