New ColorResource and ImageResource not available in Swift package

I am looking to see if I can use the new feature that generates constants from my colors and image asset catalogs. It works easy-peaze in the main application, but when I try to use it inside a Swift Package that contains asset catalogs the constants are not being created.

Feature or Bug?

  • I noticed that if I attempt to do the same in a framework created via a Cocoapod it does work, at least inside that framework.

    The bigger question I have is whether or not its possible to access the colors/images using the new syntax from a main project if the asset catalog exists in a framework / swift package?

  • I had a thought that maybe the new Settings such as ASSETCATALOG_COMPILER_GENERATE are not being inherited correctly from the project being built. So I then thought that I can add them manually to the Package.swift, but there does not appear to be "Asset Catalog Compiler" support - I do see C, CXX, Swift, and Linker support.

Add a Comment

Replies

Update: Just grabbed Xcode 15 beta 5 and it does kind of work. I can at least get the asset symbols generated for the package, so UIColor(resource: .myblue) now works inside the package. I still cannot use UIColor.myblue from inside the package. Progress!

  • Actually, I realized that the for some reason the Generate Swift Asset Symbol Extensions was not enabled by default. Flipping that flag took care of accessing the colors via UIColor.myblue as an example.

Add a Comment