How to generate localized resources using Swift Package Plugins

We have a plugin which generates a Localizable.strings for each of our languages and places them in their respective .lproj folder. In order for the iOS app to detect and use those we need them to be generated at the root of their bundle.

I tried writing directly to context.pluginWorkDirectory but it creates the following structure:

MyPackage.bundle
  MyPlugin
    *.lproj

I tried appending a path component:

MyPackage.bundle
  MyDirectory
    *.lproj

And I tried appending the .. path component, it fails which is understandable.

Are there any ways to ensure those .lproj find themselves at the root of the bundle? I need the following structure:

MyPackage.bundle
  *.lproj
    *.strings
1 Like

The WWDC session had an example involving localization, potentially that could be helpful here.

I rewatched it and they went quite quickly, not spending enough time on it to see much of a difference between their plugin and mine, could also be that genstrings writes them somewhere different?

Thought even pointing the tool to the root doesn't seem to work.