gpt4 book ai didi

swift - 生成resource_bundle_accessor,类型 'Bundle'没有成员 'module'

转载 作者:行者123 更新时间:2023-12-03 09:16:24 26 4
gpt4 key购买 nike

有时 Xcode 无法确定 module Bundle 中的参数。

Type 'Bundle' has no member 'module'


我的调查表明,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 tools.
Bundle.main.bundleURL,
]

for candidate in candidates {
let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle")
if let bundle = bundlePath.flatMap(Bundle.init(url:)) {
return bundle
}
}
fatalError("unable to find bundle named ABUIKit_ABStyleKit")
}()
}
但有时不会。为什么会这样,我怎样才能让它自动工作 再次 (无需手动实现。)
这两种情况都发生在 Xcode 12 beta.3
更新
有时它显示:

'module' is inaccessible due to 'internal' protection level


而且它根本没有显示文件。

最佳答案

SPM 生成 resource_bundle_accessor仅当对应的目标包含 resources像这样的论点:

    .target(
name: "ChenzookKit",
dependencies: ["Apollo"],
resources: [.process("Resources")] // <- `copy` or `process` doesn't really matter
),
另外,请注意它应该是有效的资源路径。
和❗️
项目 必须 实际包含 Resources 里面 目标的目录!
Example
还有❗️❗️
不要忘记构建 (cmd+b) 代码来制作 .module被创造!

关于swift - 生成resource_bundle_accessor,类型 'Bundle'没有成员 'module',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63237395/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com