fix(macos): prioritize main bundle for device resources to prevent crash

This commit is contained in:
Petter Blomberg
2026-01-01 17:22:19 +01:00
committed by Peter Steinberger
parent 5e280674f9
commit ad475239a5

View File

@@ -122,12 +122,13 @@ enum DeviceModelCatalog {
}
private static func locateResourceBundle() -> Bundle? {
// Prefer module bundle (SwiftPM/tests), then main app bundle (packaged app).
if let bundle = self.bundleIfContainsDeviceModels(Bundle.module) {
// Prefer main bundle (packaged app), then module bundle (SwiftPM/tests).
// Accessing Bundle.module in the packaged app can crash if the bundle isn't where SwiftPM expects it.
if let bundle = self.bundleIfContainsDeviceModels(Bundle.main) {
return bundle
}
if let bundle = self.bundleIfContainsDeviceModels(Bundle.main) {
if let bundle = self.bundleIfContainsDeviceModels(Bundle.module) {
return bundle
}
return nil