Xcode15 generated ImageResource with public access

Hi, for projects we used to use one SPM module for all application resources (Texts, Images, Fonts, ..) and use swiftgen to expose them safe and publicly for other modules.

I tried replacing swiftgen with the new resource catalog generation option in Xcode 15 and ran into not being able to make the generated structure public for other modules.

Is it possible to affect the generation with some parameter to add public access?

extension ImageResource {

    /// The "img_error_generic" asset catalog image resource.
    static let imgErrorGeneric = ImageResource(name: "img_error_generic", bundle: resourceBundle)

}

Thanks!

3 Likes

This is a great limitation and basically makes it unusable for us. Do you think we could write a Publify macro that goes through all the internal members of the ImageResource extension and exposes them as public with a certain prefix? The execution of the macro would have to happen after the asset symbol generation itself but I think this is the case. Something like

extension ImageResource {
    /// The "Share" asset catalog image resource.
    static let share = ImageResource(name: "Share", bundle: resourceBundle)

would be peered with

public extension ImageResource {
    /// The "Share" asset catalog image resource.
    static let iconShare = .share

Yeah, just coming up against this now.

Was hoping I wouldn't have to resort to using SwiftGen but it looks like we'll have to use SwiftGen for now.

As far as I am aware this is not possible since the macro must be applied to the ImageResource struct itself and cannot be applied to e.g. a extension since otherwise it won't see the generated properties.