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

[SR-13093] All targets in manifest erroneously being built #4529

Open
swift-ci opened this issue Jun 26, 2020 · 0 comments
Open

[SR-13093] All targets in manifest erroneously being built #4529

swift-ci opened this issue Jun 26, 2020 · 0 comments
Labels

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-13093
Radar None
Original Reporter rfree18 (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 1e01f86acfc324ac8f4fe34806f2ef17

Issue Description:

When a Package.swift file declares multiple targets in which some targets are conditional dependencies of other targets, the compiler does not correctly honor this condition. As an example:

// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.


import PackageDescription


let package = Package(
    name: "SPM-Platform-Bug",
    platforms: [
        .iOS(.v12),
        .macOS(.v10_15)
    ],
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "SPM-Platform-Bug",
            targets: ["SPM-Platform-Bug"]),
    ],
    dependencies: [
        .package(name: "Lasso", url: "git@github.com:ww-tech/lasso.git", .exact("1.0.1"))
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "SPM-Platform-Bug",
            dependencies: [
                .byName(name: "iOS-ONLY", condition: .when(platforms: [.iOS]))
            ],
            path: "Sources/SPM-Platform-Bug"
        ),
        
        .target(
            name: "iOS-ONLY",
            dependencies: [
                .byName(name: "Lasso")
            ],
            path: "Sources/iOS-ONLY"
        )
    ]
)

In this example, you can see that I have a single third party dependency called "Lasso", which heavily relies on UIKit. That framework is listed as a dependency of my "iOS-ONLY" target, which is then an iOS only dependency of my "SPM-Platform-Bug" target. The "SPM-Platform-Bug" target is the only one being vended by my package. If you resolve this package and build with macOS as the target, it will still try to compile "iOS-ONLY" and its dependencies, even though that target should not be included for macOS. It should only build the "SPM-Platform-Bug" target and correctly ignore the other one since it is not a dependency of any target being included with my macOS framework.

This bug was reproduced on Xcode 12 beta 1

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants