LocalizedStringResource's bundle

When I call this in my package:

    print(#bundle) // package bundle

it correctly returns the package' bundle.

However when I call this from my package:

    let x: LocalizedStringResource = "Hello"
    print(x.bundle) // main app bundle

it returns the main app bundle, which makes the subsequent:

String(localized: x)

fail on a missing key.

Is this a bug or a feature?

1 Like

When you construct a LocalizedStringResource from a string literal, it applies the defaults from init(_:table:locale:bundle:comment:), where bundle is set to .main. So I think it's a "feature".