It’s also possible and very convenient while unit testing or using Xcode preview to create mock objects with local image even though in real life you load image from network. For example:
let robotFixture: Robot = Robot(
name: "Bender",
image: "image_from_assets
)
Use Swift Package Manager to install. The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.
Once you have your Swift package set up, adding LoadableImage as a dependency is as easy as adding it to the dependencies value of your Package.swift.
How to use
Usage of ImageLoadable as simple as SwiftUI Image.
It’s also possible and very convenient while unit testing or using Xcode preview to create mock objects with local image even though in real life you load image from network. For example:
Consider Example project for further details.
Installation
Use Swift Package Manager to install. The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.
Once you have your Swift package set up, adding LoadableImage as a dependency is as easy as adding it to the
dependencies
value of yourPackage.swift
.Or just add package to your project:
Future plans
ImageLoadable
possible to work also with images fromAssets
catalogImageLoadable
Codable to be able use it as type in the modeldataTask
todownloadTask
to decrease memory usage for big images