How to add a .framework as dependency to a swift package in Xcode?

Viewed 2383

I want to know if there is anyway to link a swift package against a framework like SQLite.framework in Xcode? I'm trying to make a swift package for a sqlite library wrapper.

Here is my current swift package manifest:

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

import PackageDescription

let package = Package(
    name: "SQLiteDB",
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "SQLiteDB",
            targets: ["SQLiteDB"]),
    ],
    dependencies: [

        // .package(url: /* package url */, from: "1.0.0"),
    ],
    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 which this package depends on.
        .target(
            name: "SQLiteDB",
            dependencies: []),
        .testTarget(
            name: "SQLiteDBTests",
            dependencies: ["SQLiteDB"]),
    ]
)
2 Answers

I ended up creating my own Sqlite package by embedding the amalgamation sources of sqlite. This gives you the ability to have any arbitrary version of Sqlite in your apps.

With the Xcode 12 beta, you can do this if you update your swift-tools-version to 5.3, and then add a binaryTarget to your package's targets:

        .binaryTarget(
            name: "Stripe",
            url: "https://github.com/stripe/stripe-ios/releases/download/v19.3.0/Stripe.xcframework.zip",
            checksum: "fe459dd443beee5140018388fd6933e09b8787d5b473ec9c2234d75ff0d968bd"
        )
Related