简体   繁体   English

如何将 .framework 作为依赖项添加到 Xcode 中的 swift 包?

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

I want to know if there is anyway to link a swift package against a framework like SQLite.framework in Xcode?我想知道是否有任何方式将 swift 包链接到像 Xcode 中的SQLite.framework这样的框架? I'm trying to make a swift package for a sqlite library wrapper.我正在尝试为 sqlite 库包装器制作一个 swift 包。

Here is my current swift package manifest:这是我当前的 swift 包清单:

// 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"]),
    ]
)

I ended up creating my own Sqlite package by embedding the amalgamation sources of sqlite.我最终通过嵌入 sqlite 的合并源创建了自己的 Sqlite 包。 This gives you the ability to have any arbitrary version of Sqlite in your apps.这使您能够在您的应用程序中使用任意版本的 Sqlite。

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:使用 Xcode 12 测试版,如果您将 swift-tools-version 更新到 5.3,然后将 binaryTarget 添加到您的包的目标中,您就可以执行此操作:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM