Esta página se muestra en inglés. Una traducción al español está en curso.
ConfigsMay 17, 2026·2 min de lectura

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.

Listo para agents

Este activo puede ser leído e instalado directamente por agents

TokRepo expone un comando CLI universal, contrato de instalación, metadata JSON, plan según adaptador y contenido raw para que los agents evalúen compatibilidad, riesgo y próximos pasos.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
Kingfisher Overview
Comando CLI universal
npx tokrepo install e7e1fe25-520b-11f1-9bc6-00163e2b0d79

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

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados