Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to build a Swift package after adding the `RxSwift` package dependency: "product 'RxCocoa' not found"

I have created a new Swift package and trying to use the RxSwift dependency within it. I followed these instructions to add the dependency but my package is unable to build after this with the following error:

product 'RxCocoa' required by package 'mylibrary' target 'MyLibrary' not found.

My package manifest is here:

// swift-tools-version: 5.8
import PackageDescription

let package = Package(
    name: "MyLibrary",
    products: [them visible to other packages.
        .library(
            name: "MyLibrary",
            targets: ["MyLibrary"]),
    ],
    dependencies: [
        .package(url: "https://github.com/ReactiveX/RxSwift.git", .exact("6.5.0"))
    ],
    targets: [
        .target(
            name: "MyLibrary",
            dependencies: ["RxSwift", "RxCocoa"]),
        .testTarget(
            name: "MyLibraryTests",
            dependencies: ["MyLibrary"]),
    ]
)

enter image description here

I'm using Xcode 14.3. How should I add the RxSwift dependency to the package.

like image 878
Alexey Strakh Avatar asked Oct 29 '25 17:10

Alexey Strakh


1 Answers

RxCocoa isn't its own package, it's a product in the RxSwift package. Your dependencies need to be set up like this:

dependencies: [
    "RxSwift",
    .product(name: "RxCocoa", package: "RxSwift"),
]
like image 81
Daniel T. Avatar answered Oct 31 '25 10:10

Daniel T.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!