【发布时间】:2021-05-04 06:05:13
【问题描述】:
我有一个开源的 Objective C 框架,我也想使用 Swift 包管理器来提供它。
通常,我在 Xcode 项目中设置了公共标头,在构建框架时,这些标头被复制到框架包下,并在被 Xcode 链接时发现。
我不能,但是让它与 SwiftPM 一起工作。
我为我的框架创建了一个模块映射:
framework module LNPopupController {
umbrella header "LNPopupController.h"
export *
module * { export * }
}
我在 Package.swift 中这样定义库:
let package = Package(
name: "LNPopupController",
platforms: [
.iOS(.v12),
.macOS(.v10_15)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "LNPopupController",
type: .dynamic,
targets: ["LNPopupController"]),
],
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: "LNPopupController",
dependencies: [],
path: "LNPopupController",
publicHeadersPath: ".",
cSettings: [
.headerSearchPath("."),
.headerSearchPath("Private"),
]),
]
)
在 Xcode 中作为项目依赖添加时,框架编译得很好,但是当依赖目标尝试 import LNPopupController 时,会抛出错误:umbrella header 'LNPopupController.h' not found
查看构建文件夹,确实,我看到 Xcode 已经构建了一个二进制文件,但没有复制公共头文件。
有什么方法可以指定哪些标头是公开的,并让构建系统复制它们以供导入?
【问题讨论】:
-
你有没有让这个工作?把我的头发拉出来......
-
@scaly 我做到了,是的。我会用我所做的来回答我自己的问题。