SPM Resource Bundle Access #6140
-
SPM targets have a different way of searching for a bundle of resources, unlike regular xcode targets: Example: class ImageHelper {
static var resolvedBundle: Bundle {
#if SWIFT_PACKAGE
return Bundle.module
#else
return Bundle(for: self)
#endif
}
static func image(_ name: String) -> UIImage? {
return UIImage(named: name,
in: resolvedBundle,
compatibleWith: nil)
}
} Given this fact, and the fact that Tuist converts the SPM target into a regular xcode target: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
We should support resources inside SPM and they should be accessed the same way as if they were in a package. If there's a dependency where we don't generate the resource accessor correctly, would you mind raising an issue with a repro? |
Beta Was this translation helpful? Give feedback.
The resources for SPM targets are mapped in this file. We try to copy more-or-less what Apple does during build time when using the vanilla integration.