Managing localizations over multiple SwiftPM packages with main app having mutliple targets


I'm working on an App which has multiple targets and multiple SPM packages. I'm trying to figure out how to get the correct localization for the compiled target in my SPM packages to work. So far we're using a manual system where we've created a huge enum to make the translations typesafe (manually) and then use a delegate to communicate from the SPM package to the main project.
This works fine but I don't like the manual part :) so I was looking into using SwiftGen, But this can't work in a Localization SPM package as the package doesn't know which target is being compiled right? So i'm wondering if someone has a good idea on how to manage this?


Same doubt, Im stucked here

also read this:

In the end I made an SPM package with the typesafe generated localizables through SwiftGen and customized the SwiftGen script a bit so it would do like this:

static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String {
        let format = Bundle.main.localizedString(forKey: key, value: nil, table: table)
        return String(format: format, locale: .current, arguments: args)

This does mean the Localizable.Strings files are still in the base project and not in the SPM package. Maybe that will be possible in the future though

Through SwiftGen it generates something like this:

/// Sorry, something went wrong...
        public static var errorGenericTitle: String {
            if isRunningInPreviews {
                return "Sorry, something went wrong..."
            } else {
                return"Localizable", "error_generic_title")