有时 Xcode 无法确定moduleBundle 中的参数。
类型“捆绑”没有成员“模块”
我的调查表明,SPM 会在名为的文件中自动为该属性生成模块扩展(有时)resource_bundle_accessor:
import class Foundation.Bundle
private class BundleFinder {}
extension Foundation.Bundle {
/// Returns the resource bundle associated with the current Swift module.
static var module: Bundle = {
let bundleName = "ABUIKit_ABStyleKit"
let candidates = [
// Bundle should be present here when the package is linked into an App.
Bundle.main.resourceURL,
// Bundle should be present here when the package is linked into a framework.
Bundle(for: BundleFinder.self).resourceURL,
// For command-line …Run Code Online (Sandbox Code Playgroud) 正在为框架实施 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 …Run Code Online (Sandbox Code Playgroud)