Some times Xcode can not determine the module
parameter in the Bundle.
Type 'Bundle' has no member 'module'
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.)
Both situations happen on Xcode 12 beta.3
Update
Sometimes it shows:
'module' is inaccessible due to 'internal' protection level
And it's not showing the file at all.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…