我有一个开源的Objective框架,我也想使用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
实际上,查看build文件夹,我看到Xcode构建了一个二进制文件,但没有复制公共标题。
是否可以指定哪些标头是公共的,并使构建系统复制它们以供导入?
发布于 2021-05-03 22:05:13
我终于想出来了。这就是我为LNPopupController所做的
我创建了一个include/LNPopupController/子目录树,并将软链接放在那里的所有公共标题上。
在包文件中,我添加了publicHeadersPath: "include"。
您可以在这里看到最终结果:https://github.com/LeoNatan/LNPopupController/blob/master/Package.swift
这可能不是最理想的方法,但它适用于我尝试过这种方法的所有ObjC项目。
https://stackoverflow.com/questions/63211415
复制相似问题