我正在从各种 Objective-C 框架(通过使用 XCFrameworks)创建 Swift 包。
我成功创建了 SP,但在涉及到它所依赖的其他 SP 依赖项时遇到了问题。
如果我只将WrapperPackage添加到我的DemoApp中,编译器会由于缺少SubDependencyPackage框架而失败。
如果我通过 SPM 将 SubDependencyPackage 添加到DemoApp ,它编译得很好。
是否有可能/我如何...
正确地将“子依赖项” (SubDependencyPackage)捆绑到 Swift 包(WrapperPackage)中,以便在DemoApp中我只需要通过 SPM 添加WrapperPackage并且所有依赖项都已解决?
工作流程
- DemoApp添加WrapperPackage作为 SPM 依赖项。
- WrapperPackage包含 2 个 XCFrameworks。
- 2 个 XCFrameworks 是从 2 个 Objective-C 框架生成的。
- Objective-C 框架具有单独 Swift 包(SubDependencyPackage)的“子依赖项”。
DemoApp
|
--WrapperPackage (XCFrameworks)
|
--SubDependencyPackage (XCFramework Dependencies)
WrapperPackage.swift
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "WrapperPackage",
platforms: [.iOS(.v13)],
products: [
.library(name: "ObjectiveCFramework1", targets: ["ObjectiveCFramework1"]),
.library(name: "ObjectiveCFramework2", targets: ["ObjectiveCFramework2"]),
],
dependencies: [
.package(name: "SubDependencyPackage.git", url: "git@github.com:user/SubDependencyPackage.git", .branch("main")),
],
targets: [
.binaryTarget(name: "ObjectiveCFramework1", path: "XCFrameworks/ObjectiveCFramework1.xcframework"),
.binaryTarget(name: "ObjectiveCFramework2", path: "XCFrameworks/ObjectiveCFramework2.xcframework"),
]
)