MyImageLoader is a lightweight Swift Package for downloading and caching images in SwiftUI.
It provides both in-memory and disk caching, so images persist even after app relaunch.
- ✅ Asynchronous image downloading
- ✅ Memory + Disk caching support
- ✅ SwiftUI-friendly
CachedAsyncImage
view - ✅ Configurable placeholder and custom rendering
- ✅ Minimal, dependency-free, and written in Swift
- iOS 14.0+
- Swift 5.5+
- Xcode 13.0+
- Open your Xcode project
- Go to File > Add Packages
- Enter the repository URL:
https://github.com/arindam94/imageloader.git
- Select Add Package
import SwiftUI
import MyImageLoader
struct ContentView: View {
var body: some View {
VStack {
CachedAsyncImage(
url: URL(string: "https://picsum.photos/300"),
placeholder: { ProgressView() },
image: { Image(uiImage: $0).resizable() }
)
.frame(width: 200, height: 200)
.clipShape(RoundedRectangle(cornerRadius: 16))
}
}
}
CachedAsyncImage(
url: URL(string: "https://example.com/avatar.png"),
placeholder: {
ZStack {
Color.gray.opacity(0.2)
ProgressView().progressViewStyle(CircularProgressViewStyle())
}
},
image: { img in
Image(uiImage: img)
.resizable()
.scaledToFill()
}
)
.frame(width: 100, height: 100)
.clipShape(Circle())
.shadow(radius: 5)
- Memory Cache: Temporary, cleared when app is terminated
- Disk Cache: Persists images even after app relaunch
Both caches are automatically managed by the package.
Copyright © 2025 Arindam Santra.
All rights reserved. Unauthorized copying, modification, distribution, or use of this software without explicit permission is strictly prohibited.