# SDWebImage — Async Image Downloading with Cache for iOS > An asynchronous image downloading and caching library for iOS and macOS that provides UIImageView and SwiftUI categories for loading remote images with disk and memory caching. ## Install Save in your project root: # SDWebImage — Async Image Downloading with Cache for iOS ## Quick Use ```swift import SDWebImage // UIKit imageView.sd_setImage(with: URL(string: "https://example.com/photo.jpg")) // SwiftUI WebImage(url: URL(string: "https://example.com/photo.jpg")) .resizable() .scaledToFit() ``` ## Introduction SDWebImage is one of the longest-running image loading libraries in the iOS ecosystem. It provides asynchronous image downloading, multi-layer caching (memory and disk), and progressive image rendering. It supports UIKit, AppKit, and SwiftUI with a plugin architecture for extended image formats. ## What SDWebImage Does - Downloads images asynchronously with prioritized concurrent operations - Caches images in a two-tier system (NSCache for memory, disk storage with expiration) - Supports progressive JPEG loading showing partial images during download - Provides animated image support for GIF, APNG, and WebP via plugins - Offers prefetching APIs to pre-download images before they appear on screen ## Architecture Overview The library is organized around SDWebImageManager which coordinates SDWebImageDownloader (network layer) and SDImageCache (storage layer). Each download creates an SDWebImageDownloaderOperation that can be cancelled or prioritized. Image transformations are applied via SDImageTransformer protocol, and custom format support is added through SDImageCoder plugins registered at startup. ## Self-Hosting & Configuration - Install via Swift Package Manager, CocoaPods, or Carthage - Configure maximum memory cost and disk cache size through SDImageCacheConfig - Set default expiration with maxDiskAge (default 7 days) - Register custom coders for HEIF, AVIF, or WebP with SDImageCodersManager - Use SDWebImageDownloaderConfig to set max concurrent downloads and timeout ## Key Features - View category extensions for UIImageView, NSImageView, UIButton, and SwiftUI - Image transformation pipeline with built-in rounded corners, blur, and tint - Disk cache uses file-based storage with URL-based filename hashing - Supports HTTP caching headers (ETag, Last-Modified) for conditional requests - Extensible architecture with 10+ official plugins for formats and loaders ## Comparison with Similar Tools - **Kingfisher** — Swift-native with similar features; SDWebImage has longer history and Objective-C core - **Alamofire Image** — lighter but fewer caching features and no animated image support - **Nuke** — performance-focused with pipeline architecture; smaller plugin ecosystem - **Glide (Android)** — equivalent role on Android with similar caching strategies ## FAQ **Q: Does SDWebImage support SwiftUI?** A: Yes, the SDWebImageSwiftUI package provides WebImage and AnimatedImage views for SwiftUI. **Q: How do I clear the cache?** A: Call SDImageCache.shared.clearMemory() and SDImageCache.shared.clearDisk() for full cache reset. **Q: Can it handle WebP images?** A: Yes, install the SDWebImageWebPCoder plugin and register it at app startup. **Q: Is it compatible with Mac Catalyst?** A: Yes, it fully supports Mac Catalyst, macOS via AppKit, and all Apple platforms. ## Sources - https://github.com/SDWebImage/SDWebImage - https://sdwebimage.github.io/ --- Source: https://tokrepo.com/en/workflows/asset-bba46d6c Author: AI Open Source