代码之家  ›  专栏  ›  技术社区  ›  Jay Patel

包裹swift文件包含GitHub和Xcode中SPM上的不同数据。如何将二进制目标添加到SPM?

  •  0
  • Jay Patel  · 技术社区  · 3 年前

    我正在创建包含XCFramework二进制目标的Swift包。我在跟踪 https://www.appcoda.com/xcframework/ 文章旨在实现这一目标。

    我所遵循的且工作良好的步骤是:

    1. 为iOS和模拟器创建了XC框架
    2. 已存档的框架(iOS和Sim卡)到。XC框架通过终端。(本地框架运行良好)
    3. 将xcframework压缩为zip文件,并上传到GitHub上的public repo
    4. 生成xcframework的校验和。拉链
    5. 创建Swift包(已删除测试、默认文件夹和“源”文件夹中的文件)
    6. 将标签1.0.0提供给Swift软件包,并推送到GitHub公共存储库。
    7. 创建了全新的iOS应用程序,并通过SPM添加了上述Swift软件包。

    现在是包裹的内容。swift文件与GitHub不同。

    包裹GitHub上的swift文件:

    let package = Package(
        name: "XIBLoadable",
        products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
            .library(
                name: "XIBLoadable",
                targets: ["XIBLoadable"]),
        ],
        dependencies: [
            // Dependencies declare other packages that this package depends on.
            // .package(url: /* package url */, from: "1.0.0"),
        ],
        targets: [
            .binaryTarget(name: "XIBLoadable",
                          url: "https://github.com/iamjdpatel/XIBLoadable/blob/main/XIBLoadable.xcframework.zip",
                          checksum: "d76716757565af8371be595c840f79ca81571a6b23f4c64962f6adc8572ed134")
        ]
    )
    

    包裹Xcode中的swift文件(默认包文件)

    let package = Package(
        name: "XIBLoadableRemote",
        products: [
            // Products define the executables and libraries a package produces, and make them visible to other packages.
            .library(
                name: "XIBLoadableRemote",
                targets: ["XIBLoadableRemote"]),
        ],
        dependencies: [
            // Dependencies declare other packages that this package depends on.
            // .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 this package depends on.
            .target(
                name: "XIBLoadableRemote",
                dependencies: []),
            .testTarget(
                name: "XIBLoadableRemoteTests",
                dependencies: ["XIBLoadableRemote"]),
        ]
    )
    

    我错过了什么?为什么xcframework的二进制文件不与SPM一起提供?

    提前谢谢。

    0 回复  |  直到 3 年前
    推荐文章