生成resource_bundle_accessor,类型'Bundle'没有成员'module' [英] Generating resource_bundle_accessor, Type 'Bundle' has no member 'module'
问题描述
有时Xcode无法确定捆绑软件中的 module
参数.
Some times Xcode can not determine the module
parameter in the Bundle.
捆绑"类型没有成员模块"
Type 'Bundle' has no member 'module'
我的调查表明,SPM有时会在名为 resource_bundle_accessor
的文件中自动为此属性在模块上生成扩展,例如:
My investigations show that SPM generates an extension on the module (some times) for this property automatically in a file called resource_bundle_accessor
like:
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")
}()
}
但是有时候不会.为什么会这样,以及如何使它自动再次(无需手动实施).
But sometimes it won't. Why is that and how can I make it work automatically again (Without the need to manually implement that.)
两种情况都发生在 Xcode 12 beta.3
有时它显示:
由于内部"保护级别,无法访问模块"
'module' is inaccessible due to 'internal' protection level
它根本不显示文件.
推荐答案
仅当相应的目标包含 resources
时,SPM才会生成 resource_bundle_accessor
.像这样的参数:
SPM generates the resource_bundle_accessor
only if the corresponding target contains resources
as the argument like:
.target(
name: "ChenzookKit",
dependencies: ["Apollo"],
resources: [.process("Resources")] // <- `copy` or `process` deson't really matter
),
此外,请注意,它应该是有效的资源路径.
项目必须实际上包含目标对象目录中的资源
!
The project MUST actaully contains Resources
inside the target's Directory!
这篇关于生成resource_bundle_accessor,类型'Bundle'没有成员'module'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!