I am migrating an app to Swift Package Manager. All my images are in an .xcassets, with their configurations for different display sizes etc.
How can I migrate those assets to SPM?
I am migrating an app to Swift Package Manager. All my images are in an .xcassets, with their configurations for different display sizes etc.
How can I migrate those assets to SPM?
Starting with XCode 12 and Swift 5.3, it is possible to include images in Swift Package. I had to do a few modifications:
// swift-tools-version:5.3 as the header of the Swift package file.assets folder get compiled automatically.
public func SCImage(named name: String) -> UIImage? {
UIImage(named: name, in: Bundle.module, compatibleWith: nil)
}
I can now do
import SCImages
let image = SCImage(named: "foo")