SmartImages is a powerful and flexible Swift library that makes loading images fast, smooth, and efficient. Whether you're building a UIKit or SwiftUI app, SmartImages helps you prioritize, download, and cache images intelligently—with minimal setup.
Here's how to load an image into a UIImageView
with a placeholder:
import SmartImages
imageView.setImage(withURL: URL(string: "https://example.com/image.jpg")!,
placeholder: .image(.defaultPlaceholder),
animated: .fade(duration: 0.3))
You can also cancel requests:
imageView.cancelImageRequest()
- ⚡ Prioritized downloads (e.g., on-screen images are prioritized)
- 🧠 Efficient memory and disk caching
- 📱 Works with both UIKit and SwiftUI
- 🔧 Easy integration with your own networking layer
- ⏱ Configurable download concurrency and caching limits
- 🔄 Prefetching support for a smoother experience
- Ideal for image-heavy apps like news, social, or e-commerce.
- Handles memory pressure gracefully with caching.
- Provides fine control over download performance.
- Decouples your UI code from image loading logic.
Coordinates all image loading logic: networking, caching, and queuing.
Stores images in memory and disk with the following defaults:
- Memory: 40MB
- Disk: 400MB
Handles prioritization and concurrency of downloads—favoring what’s currently visible.
A protocol you implement to plug in URLSession
, Alamofire, or any custom networking layer.
imageView.setImage(withURL: url, placeholder: .image(.defaultPlaceholder))
imageView.setImage(withURL: url, animated: .fade(duration: 0.3))
imageView.cancelImageRequest()
- In Xcode, go to File > Add Packages...
- Use the URL:
https://github.com/NikSativa/SmartImages.git
- Select the latest version and click Add Package.
Then just import:
import SmartImages
You can use your preferred networking system by implementing the ImageDownloaderNetwork
protocol. Here’s how to wire it up with either:
let customDownloader = ImageDownloader(
network: ImageDownloaderNetworkAdaptor(manager: RequestManager.create()),
cache: .init(folderName: "DownloadedImages"),
concurrentLimit: 8
)
let customDownloader = ImageDownloader.create(
network: ImageDownloaderNetworkAdaptor(),
cache: .init(folderName: "DownloadedImages"),
concurrentImagesLimit: 8
)
- iOS 13+
- macOS 11+
- macCatalyst 13+
- tvOS 13+
- watchOS 6+
- visionOS 1+
SmartImages is available under the MIT license. See the LICENSE
file for details.
We welcome contributions! Feel free to open an issue or PR. To get started:
- Fork the repo
- Make your changes
- Submit a pull request
Star ⭐️ the repo to show support and get updates. Follow @NikSativa for more open-source Swift projects.