# Kingfisher — Pure Swift Image Downloading and Caching > A lightweight pure-Swift library for downloading and caching images from the web, with built-in support for UIKit, AppKit, SwiftUI, and image processing. ## Install Save in your project root: # Kingfisher — Pure Swift Image Downloading and Caching ## Quick Use ```swift import Kingfisher // UIKit imageView.kf.setImage(with: URL(string: "https://example.com/image.png")) // SwiftUI KFImage(URL(string: "https://example.com/image.png")) .placeholder { ProgressView() } .resizable() .scaledToFit() ``` ## Introduction Kingfisher is a pure-Swift library for downloading and caching images from the web. It provides a clean API with view extensions for UIKit and SwiftUI, handling the complexity of async downloading, memory and disk caching, and image processing in a type-safe Swift-native way. ## What Kingfisher Does - Downloads images asynchronously with configurable request modifiers - Implements multi-layer caching with memory (NSCache) and disk storage - Processes images on download with built-in and custom processors - Provides prefetching for collection views to preload upcoming images - Supports animated image formats including GIF and APNG ## Architecture Overview Kingfisher centers around KingfisherManager which orchestrates ImageDownloader and ImageCache. Downloads go through a session-based pipeline with request modifiers and retry strategies. Retrieved data passes through ImageProcessor instances before caching. The cache layer is keyed by URL with optional custom keys, and supports configurable memory limits and disk expiration policies. ## Self-Hosting & Configuration - Install via Swift Package Manager: add the Kingfisher repository URL - Configure cache limits with ImageCache.default.memoryStorage.config.totalCostLimit - Set disk cache expiration via ImageCache.default.diskStorage.config.expiration - Customize the downloader session configuration for certificate pinning - Use ImagePrefetcher with collection view data sources for smooth scrolling ## Key Features - Written entirely in Swift with full Swift concurrency (async/await) support - View extensions for UIImageView, NSImageView, UIButton, and SwiftUI views - Built-in processors: resize, round corner, blur, tint, and overlay - Retry mechanism with configurable max count and delay strategy - Cancellation support that propagates through the download-process-cache pipeline ## Comparison with Similar Tools - **SDWebImage** — Objective-C core with Swift wrappers; Kingfisher is pure Swift with modern language features - **Nuke** — performance-optimized with pipeline architecture; Kingfisher offers simpler API surface - **Alamofire Image** — thin extension on Alamofire; less caching sophistication - **Coil (Android)** — Kotlin-native equivalent with coroutine integration on Android ## FAQ **Q: Does Kingfisher support async/await?** A: Yes, all APIs have async/await alternatives starting from version 7.0. **Q: How do I show a loading indicator?** A: Use the .placeholder option with any UIView or SwiftUI view, or enable the built-in activity indicator via .indicatorType. **Q: Can I cache processed images separately?** A: Yes, processors automatically generate unique cache keys so original and processed versions are stored independently. **Q: Is Kingfisher compatible with visionOS?** A: Yes, version 7.x supports iOS, macOS, tvOS, watchOS, and visionOS. ## Sources - https://github.com/onevcat/Kingfisher - https://swiftpackageindex.com/onevcat/Kingfisher --- Source: https://tokrepo.com/en/workflows/asset-e7e1fe25 Author: AI Open Source