When Swift Package Manager builds a target with resources, it automatically creates and adds a file to the module called
resource_bundle_accessor.swift. This file's contents are roughly equivalent to:
Code Block swiftimport Foundation |
extension Bundle { |
static let module = Bundle(path: "\(Bundle.main.bundlePath)/path/to/this/targets/resource/bundle") |
} |
Which adds a static
module property to Foundation's
Bundle type. The property is not
public, so this static property exists only in the specific target that owns the bundle's resources—other modules will either have their own version of
Bundle.module which returns their bundle, or won't have a
Bundle.module property at all.
Since this property is created by adding a file to your target, it isn't technically part of Foundation, so it's not listed in the Foundation documentation. However, including it in the Foundation documentation anyway isn't a bad idea! Please use
Feedback Assistant to file this suggestion.