Can Bundle(for: MyClass.self) be used with SPM bundles?

I didn’t see in the video if .module was a new convenience or the only real way to access the bundle. Is Bundle(for: Class) usable? Apologies if I’ve misremembered the exact call.

Replies

Bundle.module is the only supported way to access the resource bundle of a Swift package target.
To elaborate on this: Swift Package libraries are often built statically, so the code and the resources might end up in different bundles (the code is linked into the client, while the resources are put into a separate resources bundle that's embedded in the client). That's why the generated .module accessor is the only way to access the resource bundle.