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-15589] Conditional target dependencies not working as expected in Package.swift #4370

swift-ci opened this issue Dec 13, 2021 · 3 comments


Copy link

@swift-ci swift-ci commented Dec 13, 2021

Previous ID SR-15589
Radar None
Original Reporter Cameron (JIRA User)
Type Bug

macOS 12.0.1, Xcode 13.2 (13C90)

macOS 12.3, Xcode 13.3 (13E113)

Additional Detail from JIRA
Votes 1
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 1d817448ccceb0cac34d0ba118636b94

Issue Description:

I am working on a library for iOS and macOS platforms. When on iOS, I'd like to include a specific, iOS only, dependency. I am using conditional target dependencies to achieve this:

import PackageDescription

let package = Package(
    name: "MyLibrary",
    products: [
        .library(name: "MyLibrary", targets: ["MyLibrary"])
    dependencies: [
        .package(name: "Embrace", url: "", from: "5.7.0")
    targets: [
            name: "MyLibrary",
            dependencies: [
                .product(name: "Embrace", package: "Embrace", condition: .when(platforms: [.iOS]))

However, when I compile on a macOS target, I get the following error which feels incorrect to me:

/Users/cbp/Library/Developer/Xcode/DerivedData/MyLibrary-hbfrabjxsrphnbbioeeyckityvdv/SourcePackages/checkouts/embrace-spm/Embrace.xcframework:1:1: While building for macOS, no library for this platform was found in '/Users/cbp/Library/Developer/Xcode/DerivedData/MyLibrary-hbfrabjxsrphnbbioeeyckityvdv/SourcePackages/checkouts/embrace-spm/Embrace.xcframework'.

It's true that the Embrace library does not have a macOS version, but I had figured my condition: .when(platforms: [.iOS]) would work around that.

Copy link
Contributor Author

@swift-ci swift-ci commented Mar 16, 2022

Comment by Cameron (JIRA)

I am still seeing this issue in Xcode 13.3 (13E113).

Copy link
Contributor Author

@swift-ci swift-ci commented Apr 15, 2022

@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
Copy link

@loganblevins loganblevins commented May 12, 2022

Bumping this. Running Xcode 13.3 toolchain with Swift 5.5 and still an issue. Conditional product dependencies not respected if said dependencies also depend on their own binary targets (e.g. xcframework).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

3 participants