What this thread does
Do first: check the resource declaration on the target that calls Bundle.module.
Short answer
For Type 'Bundle' has no member 'module', check resource membership before adding a hand-written accessor. As of November 2026, SwiftPM generates an internal static Bundle extension for each module it compiles; modules without resources have no resource bundle or declaration. Resource declarations require Swift tools 5.3 or later; Swift 5.3's September 16, 2020 release and SE-0271 establish the introduction boundary.
Choose / don't choose
.process: choose for platform processing; when no special processing is available, resources are copied to the bundle’s top-level directory (Apple)..copy: choose for untouched files or a directory whose structure must survive; expect the resource to be copied as is (Apple).- Target-local accessor: choose
Bundle.moduleinside the resource-owning module; expose a public resource API if clients need access. Don't expect another target's internal accessor to become visible (SE-0271).
Not for: Swift Codable unknown-value decoding; see swift-codable-unknown-enum-case-fallback.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
swift-tools-version | At least 5.3 for target resources; retain a higher minimum if other manifest APIs require it | Resource API introduced in Swift 5.3 | manifest, proposal |
resources / .process | [.process("text.txt")] in the MyLibrary target example; process recursively | Current SwiftPM resource API | Apple |
resources / .copy | Use the copy rule with a directory path to preserve that directory's structure and contents | Current SwiftPM resource API | Apple |
exclude | The source converts target.exclude to excludedPaths | Current SwiftPM source | discovery source |
defaultLocalization | Set defaultLocalization when localized resources are present | Current manifest / localized bundles | manifest, report |
Order of operations
1. Locate the failing Swift file's target. Put resource files under that target's directory, typically Sources/MyLibrary/Resources; check spelling, case (Apple). 2. Read target path, resources and exclude together. The source constructs declared resource paths with AbsolutePath(validating: $0.path, relativeTo: path) (discovery source). 3. Build the same target that references Bundle.module. The accessor is visible only to code within the same module. SE-0271 makes the accessor internal and omits it for modules without resources (proposal). 4. For a localized bundle, resolve localization diagnostics too. yakovmanshin's January 26, 2024 report describes that Bundle.module was unavailable because defaultLocalization was not set. Treat that report as a diagnostic example, not proof of a universal current compiler defect.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|
| manifest property 'defaultLocalization' not set | Localized resources have no default localization in the reported package | Set defaultLocalization in Package.swift | report, manifest |
Missing
- No generated accessor is promised for an empty resource directory. Xcode's automatic recognition of Apple resource types is not a substitute for correct package target membership.
Checked
2026-11-12; current SwiftPM/Apple resource docs, SE-0271, Swift 5.3 release and yakovmanshin's dated report read. No package build executed.
Started from a post by @Apple, packaged by the editor. Original post