Skip to content

Guide · Open source

How to use Kingfisher: install and load images in Swift

Updated · written with AI from the project's own documentation and checked against our catalogue data

Kingfisher is an MIT-licensed Swift library for downloading images from URLs and caching them in memory and on disk. It is aimed at developers building iOS, macOS, tvOS, watchOS or visionOS apps that show remote images. After this guide you will know how to add it with Swift Package Manager, load an image into a view, and apply a processor such as downsampling.

Kingfisheronevcat/Kingfisher · ★ 24.4k · MIT

Quick start

  1. 1Check your requirements. Confirm your platform, Xcode and Swift versions against the release you plan to use.
  2. 2Add the package. In Xcode, choose File > Swift Packages > Add Package Dependency and enter https://github.com/onevcat/Kingfisher.git.
  3. 3Select a version. Choose Up to Next Major with 8.0.0 as the README suggests.
  4. 4Import Kingfisher. Add import Kingfisher at the top of the file where you load images.
  5. 5Load an image. Call imageView.kf.setImage(with:) for UIKit, or use KFImage in SwiftUI, passing a URL.
  6. 6Add a processor if needed. Pass a processor such as DownsamplingImageProcessor through the options to resize images.

Check the requirements before you install

Kingfisher's minimum platform and Swift versions depend on which release you choose. The current development branch needs iOS 15.0+, macOS 12.0+, tvOS 15.0+, watchOS 9.0+ or visionOS 1.0+, with Xcode 26.0+ and the Swift 6.2+ compiler.

Kingfisher 8.0 needs Swift 5.9+. For UIKit and AppKit it supports iOS 13.0+ and macOS 10.15+, and for SwiftUI iOS 14.0+ and macOS 11.0+.

  • Current development branch: iOS 15.0+ / macOS 12.0+ / tvOS 15.0+ / watchOS 9.0+ / visionOS 1.0+, Xcode 26.0+, Swift 6.2+
  • Kingfisher 8.0: Swift 5.9+, UIKit/AppKit iOS 13.0+ / macOS 10.15+
  • Older releases such as Kingfisher 7.0 list different minimums, so check the README for your version

Install Kingfisher with Swift Package Manager

The README's method is to add the package in Xcode. Choose File > Swift Packages > Add Package Dependency, then enter the repository URL. The README suggests selecting "Up to Next Major" with "8.0.0" to get the 8.x line.

CocoaPods and a pre-built framework are also documented, but Swift Package Manager is the route this guide follows.

  • Open your project in Xcode and choose File > Swift Packages > Add Package Dependency.
  • Enter the repository URL and select "Up to Next Major" with "8.0.0".
  • Add the package to your app target.
https://github.com/onevcat/Kingfisher.git

Load an image into a UIKit view

The simplest use is the kf extension on UIImageView. Import Kingfisher, create a URL, and call setImage. Kingfisher downloads the image, stores it in the memory and disk caches, and shows it in the view.

When you set the same URL again later, the image comes from the cache and appears immediately.

import Kingfisher let url = URL(string: "https://example.com/image.png") imageView.kf.setImage(with: url)

Use Kingfisher in SwiftUI

For SwiftUI, use the KFImage view instead of the kf extension. Pass it a URL, and it handles loading the same way.

var body: some View { KFImage(URL(string: "https://example.com/image.png")!) }

Resize and style images with processors

Processors change an image before it is shown. The README example combines DownsamplingImageProcessor, which fits the image to the view size, with RoundCornerImageProcessor. It also adds a placeholder, an activity indicator, a fade transition and caching of the original image.

Use a downsampling processor when you load large images into small views, so the app does not keep more pixels than it displays.

  • DownsamplingImageProcessor(size:) matches the image to the view size.
  • RoundCornerImageProcessor(cornerRadius:) rounds the corners.
  • The .cacheOriginalImage option stores the full-size image on disk for later use.
let url = URL(string: "https://example.com/high_resolution_image.png") let processor = DownsamplingImageProcessor(size: imageView.bounds.size) |> RoundCornerImageProcessor(cornerRadius: 20) imageView.kf.indicatorType = .activity imageView.kf.setImage( with: url, placeholder: UIImage(named: "placeholderImage"), options: [ .processor(processor), .scaleFactor(UIScreen.main.scale), .transition(.fade(1)), .cacheOriginalImage ])

Use the parts you need on their own

Kingfisher's components are independent. The README lists the downloader, the caching system and the image processors as separate pieces you can use alone. The documentation has pages for cache, downloader and processor tasks, linked from the README.

Cache controls include a customizable expiration date and size limit. If your caching rules are more unusual than these, check the documentation before you rely on the library for them.

  • Common Tasks - Cache, Common Tasks - Downloader and Common tasks - Processor are listed in the README documentation section.
  • Kingfisher 8.0 Migration notes are available if you are upgrading.

What people use it for

  • Showing remote avatars or photos in a UITableView or UICollectionView list
  • Displaying large images in a detail screen after downsampling them to the view size
  • Building a SwiftUI screen that loads images from URLs with KFImage
  • Caching images on disk so a second visit to the same screen loads instantly

Frequently asked questions

Is Kingfisher free to use?

Yes. Kingfisher is licensed under the MIT License, as shown on the repository's license badge. Check the LICENSE file in the repository for the full terms.

How do I install Kingfisher?

The README recommends Swift Package Manager: in Xcode, choose File > Swift Packages > Add Package Dependency and enter https://github.com/onevcat/Kingfisher.git. CocoaPods and a pre-built framework are also documented.

What are the requirements for Kingfisher?

The current development branch requires Xcode 26.0+ and Swift 6.2+. Kingfisher 8.0 requires Swift 5.9+. Minimum OS versions differ by release and by UIKit/AppKit versus SwiftUI, so check the README.

Does Kingfisher work with SwiftUI?

Yes. The README shows KFImage, which takes a URL in a SwiftUI body. Use the same library for UIKit and AppKit views through the kf extension.

Can I use Kingfisher on Android or the web?

No. The library is pure Swift for Apple platforms, so it does not run on Android or the web.

What are alternatives to Kingfisher?

The comparable projects listed for this directory are SDWebImage, Nuke and Alamofire Image. This guide does not compare their features, so read each project's documentation before choosing.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Kingfisher suits Swift developers on Apple platforms who need to load, cache and resize remote images without writing that code themselves, in UIKit, AppKit or SwiftUI. It is not a fit for non-Swift projects, for caching rules that go beyond its expiration and size controls, or for projects stuck on Swift versions older than the release they need.

Install options & downloads