ImageStreamer is a lightweight, high-efficiency image loading library, built entirely with Swift Concurrency (async/await).
- Task Coalescing: Merges duplicate requests for the same URL automatically.
- Task Cancellation: Controlled cancel requests when they're no longer needed: checks for task cancellation before making a network request, and before intensive CPU and memory usage.
- Background Decoding & Downsampling: smooth scrolling and lesser memory usage.
- Smart Caching:
NSCache, light, thread-safe, and gracefully prunes itself —It won't crash your app with an Out-of-Memory (OOM) error - Native Async/Await: Clean, readable, and safe code.
- SwiftUI Ready: Seamless integration via
EnvironmentValues.
ImageStreamer leverages native system decoders. Support depends on whether you are using downsampling (pointSize parameter).
| Format | Downsampled | Full-Size |
|---|---|---|
| Raster (JPEG, PNG, HEIC, WebP) | ✅ Full Support | ✅ Full Support |
| GIF | ||
| Vector (SVG, PDF) | ❌ Not Supported |
For more technical details, see the Advanced Topics section.
- Usage Guide: Setup and basic usage.
- Advanced Topics: Architecture, Performance details, Instrumentation, and Testing.
- Showcase App Walkthrough: Packed as a Swift Playground app
.swiftpm. A grid of images with infinite scrolling.
Add ImageStreamer to the dependencies value of your Package.swift:
dependencies: [
.package(url: "https://github.com/nomasystems/image-streamer.git", from: "1.0.1")
]Then, add the package product to your target's dependencies:
targets: [
.target(
name: "YourApp",
dependencies: ["ImageStreamer"]
)
]- Open your project in Xcode.
- Go to File > Add Package Dependencies...
- Enter the repository URL:
https://github.com/nomasystems/image-streamer.git - Set the Dependency Rule to Up to Next Major Version and enter
1.0.1. - Select the project target where you want to use the library.
The entire ImageStreamer sits behind protocols (ImageStreamerProtocol, ImageFetching), which makes it simple to provide your own caches or mock networks for unit testing.
public init(
session: ImageFetching = URLSession.shared,
cache: NSCache<ImageCacheKey, PlatformImage> = NSCache(),
instrumentation: ImageStreamerInstrumentation? = nil
)For instance, you might want to create an ImageFetching layer that attaches Auth tokens, applies custom retry logic, or pulls from a local disk cache before hitting URLSession.
This project is licensed under the MIT License - see the LICENSE file for details.