【发布时间】:2020-11-16 17:14:05
【问题描述】:
我的库由两个模块组成:
- Swift 中的库核心
- 包含 CHTMLSAXParser 的 C 语言模块
这是结构
现在为了在 SPM 中编译它,我需要创建两个目标:
import PackageDescription
let package = Package(
name: "MyLib",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "MyLib",
targets: ["MyLib"]),
],
dependencies: [],
targets: [
.target(
name: "CHTMLSAXParser",
dependencies: []),
.target(
name: "MyLib",
dependencies: ["CHTMLSAXParser"])
]
)
这很简单:在 MyLib 中,一个源 swift 文件调用 import CHTMLSAXParser 并且一切正常。
但是我不知道用 CocoaPods podspec 文件复制相同行为的正确方法是什么。
有什么想法吗?
【问题讨论】:
-
你想要一个 podspec 和一个 subpodspec。你试过什么?
-
我尝试过使用 subpodspec 但它不起作用gist.github.com/malcommac/31aea9a80bd5670ae0a8f606681003ea 它只是无法识别我的主库中的模块:` - 错误 | [MyLib/Core] xcodebuild: /.../EscapeSpecialCharacters.swift:22:8: 错误:没有这样的模块'CHTMLSAXParser'`