在实现框架的SPM时遇到了Type 'Bundle' has no member "module"
错误。
我看到了两篇关于此问题的最近帖子,分别位于这里和这里,但是按照所有步骤进行后,对我仍然无效,没有生成resource_bundle_accessor
文件。
我在这里询问了我的Package.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: "BioSwift",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "BioSwift",
targets: ["BioSwift"]
)
],
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: "BioSwift",
dependencies: [],
resources: [
.process("Resources")
]
),
.testTarget(
name: "BioSwiftTests",
dependencies: ["BioSwift"]
)
]
)
尝试访问捆绑包中的一项资源时,我遇到了 Type 'Bundle' has no member "module"
错误:
public let unimodURL = Bundle.module?.url(forResource: "unimod", withExtension: "xml")
项目在 GitHub 上,这里
。
.process("Resources")
在哪里? - Mojtaba Hosseiniswift-tools-version:5.3
来访问资源。 - Mojtaba Hosseini