我正在尝试为我的图书馆添加 SPM 支持。我需要为我的库的目标之一定义 unsafeFlags
(为了将 Swift 代码导入 Objective-C++):
.target(name: "MyLibrary",
dependencies: ["MyOtherTarget"],
cSettings: [
.unsafeFlags(["-fmodules", "-fcxx-modules"]),
.define("BUILDING_FOR_SPM")
]
),
生成的包构建。但是当我将它导入主机应用程序时,它无法构建,因为
The package product 'MyLibrary' cannot be used as a dependency of this target because it uses unsafe build flags.
根据 this post和相应的pull request ,问题已在 Swift 4 中得到解决。我使用的是 Xcode 12.5 和 Swift 5。
这是怎么回事?
最佳答案
.unsafeFlags
不允许用于指定版本的依赖项。解决方法是使用提交哈希指定版本。
在 https://forums.swift.org/t/override-for-unsafeflags-in-swift-package-manager/45273 上对 monorepos 进行了详细讨论和另一种解决方法
关于ios - 包产品 'MyLibrary' 不能用作此目标的依赖项,因为它使用了不安全的构建标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67889931/