[Idea] UI assets defined entirely in Swift, with preview support in Xcode

I'm not entirely sure this belongs to this forum, it might be that the possible implementation involves the language too, but maybe not.

Problem: Xcode asset catalogs are an outdated technology that haven't changed ever since they were introduced if I'm not mistaken. Managing assets is a cumbersome process that involves a lot of clicks for trivial operations.

Solution: in the spirit of "everything is Swift" like it was done with package management, assets too, could be defined in Swift. Moreover Xcode could support previewing of assets similar to how SwiftUI views are previewed in the side pane, except this wouldn't even require a simulator.

The vision is to have something like this:

Similarly, image assets could be defined (and previewed) by pointing to a resource, i.e.

extension Image {
    static let brandingBG = Asset("Images/brandingBG.svg", renderAs: .original)
    // ...
}

... and the old asset catalogs could go away entirely.

Overall, pros:

  • much easier to add resources and manage them, saves time
  • asset definitions in Swift are included in the module build directly, therefore:
  • extra build steps such as asset symbol generation, also packing the assets in the bundle are no longer needed
  • potentially easier to generate asset catalogs from scripts if needed

Cons:

  • App Store seems to be treating the assets in each bundle in a special way, but I have no idea how all that works (is it just the app icons, or everything?). But by defining assets in Swift and incorporating graphical assets in bundle resources directly, it seems like there'd be nothing for the App Store to do anymore.

If this is off-topic here, feel free to remove but I'd appreciate if you could tell me where suggestions like this could be posted.

Thanks!

2 Likes