ios – How to add dependency for xcframeworks in SPM Package

0
25

[ad_1]

I have created xcframework for.eg. MobileCoreFramework and distributed it through MobileCoreSPM,
here is MobilecoreSPM package,

    name: "MobileCoreSPM",
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "MobileCoreSPM",
            targets: ["MobileCoreSPM","MobileCoreFramework"]),
    ],
    dependencies: [

    ],
    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: "MobileCoreSPM",
            dependencies: ["MobileCoreFramework"]),
        .binaryTarget(name: "MobileCoreFramework", path: "Artifacts/MobileCoreFramework.xcframework"),
    ]
)

then created another XCframework i.e. BillpayFramework which depends on MobileCoreFramework, here when creating BillpayFramework, I used MobileCoreSPM as dependent package and used MobilecoreMethods inside Billpay class, which was working fine.

but when tried to distribute BillpayFramework through BillpaySPM, error is displayed like it x-product ‘MobileCoreFramework’ required by package ‘billpaylib’ target ‘BillpaySPM’ not found.

let package = Package(
    name: "BillpaySPM",
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "BillpaySPM",
            targets: ["BillpaySPM"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        .package(path: "/Users/com/Documents/POC/Try2/MobileCoreLib"),
    ],
    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: "BillpaySPM",
            dependencies: ["BillpayFramework","MobileCoreFramework",
                          ]),
        .binaryTarget(name: "BillpayFramework", path: "Artifacts/BillpayFramework.xcframework"),
    ]
)

And I am trying all this in my machine locally, didnt host it in github yet, hence linked everything through localpath.

Error:

product ‘MobileCoreFramework’ required by package ‘billpaylib’ target ‘BillpaySPM’ not found.
enter image description here

[ad_2]