Swift Package Manager - Type 'Bundle' has no member “module” error
Besides all errors in the test file, the only issue remains is that module
is not an optional
. To fix that, just change this:
public let unimodURL = Bundle.module?.url(forResource: "unimod", withExtension: "XML")
to:
public let unimodURL = Bundle.module.url(forResource: "unimod", withExtension: "xml")
Update:
If you use .xcodeproj
file, you will continue seeing this error. You should consider opening it with the package.swift
or import it as a package (instead of converting it to a project)!
by the way, here is the generated file, so you can add it as a development asset when you are working with the xcodeproject:
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 = "BioSwift_BioSwift"
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 BioSwift_BioSwift")
}()
}
Generating resource_bundle_accessor, Type 'Bundle' has no member 'module'
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` doesn't really matter
),
Also, note that it should be a valid resource path.
AND❗️
The project MUST actaully contains Resources
inside the target's Directory!
AND❗️❗️
Don't forget to build (cmd+b) the code to make the .module
be created!
Swift Package Manager with resources compile errors
You missed a ,
after the target
close parentheses:
.target(
name: "BioSwift",
resources: [
.process("Resources/unimod.xml"),
.process("Resources/aminoacids.json"),
.process("Resources/elements.json"),
.process("Resources/enzymes.json"),
.process("Resources/functionalgroups.json"),
.process("Resources/hydropathy.json")
]
), // Here is the missed `,`
Also, you don't need to add files one by one! Instead, you can add a directory:
.process("Resources")
Related Topics
Cannot Read the Nfc Chip of the Epassport Using iOS13
What Is Other Option Available in Swift Instead of Refactoring and Renaming Class or Attribute Name
Nstextalignment.Justified for Uilabel Does Not Work
Nsbundle.Mainbundle().Urlforresource("Bach1", Withextension: "Jpg") Returning Null
Is String Type a Class or a Struct? or Something Else
Leading Zeros for Float in Swift
Swift 4 Codable - API Provides Sometimes an Int Sometimes a String
How to Add Constraints Programmatically to My Uilabel
Adding a View to the Window Hierarchy
Swiftui - Foreach Deletion Transition Always Applied to Last Item Only
"Cannot Inherit from Non-Open Class" Swift
How to Set an Attributed Title Color for State in Swift
Realm Mobile Platform, How to Connect While Offline
Swiftui Navigation on iPad - How to Show Master List
Nsundomanager Casting Nsundomanagerproxy Crash in Swift Code