Installation Guide

onevcat edited this page Dec 6, 2018 · 7 revisions

Everything has a beginning. For using a framework, it's installation.

Versions

Kingfisher supports from Swift 4 from version 5.0. If you are trying to use Kingfisher with an earlier Swift version, see the release page to find what you need. We will use the latest version in this guide. But the installation process should be the same for all versions except the version number.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate Kingfisher into your Xcode project using CocoaPods, specify it to a target in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target 'MyApp' do
  # your other pod
  # ...
  pod 'Kingfisher', '~> 5.0'
end

Then, run the following command:

$ pod install

You should open the {Project}.xcworkspace instead of the {Project}.xcodeproj after you installed anything from CocoaPods.

For more information about how to use CocoaPods, I suggest this tutorial.

Carthage

Carthage is a decentralized dependency manager for Cocoa application. To install the carthage tool, you can use Homebrew.

$ brew update
$ brew install carthage

To integrate Kingfisher into your Xcode project using Carthage, specify it in your Cartfile:

github "onevcat/Kingfisher" ~> 5.0

Then, run the following command to build the Kingfisher framework:

$ carthage update

At last, you need to set up your Xcode project manually to add the Kingfisher framework:

  1. On your application targets’ “General” settings tab, in the “Linked Frameworks and Libraries” section, drag and drop each framework you want to use from the Carthage/Build folder on disk.

  2. On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script with the following content:

/usr/local/bin/carthage copy-frameworks
  1. Add the paths to the frameworks you want to use under “Input Files”:
$(SRCROOT)/Carthage/Build/iOS/Kingfisher.framework
  1. Add the paths to the copied frameworks to the “Output Files”:
$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Kingfisher.framework

In step 3 and 4, you may choose another framework (like Kingfisher-macOS.framework) if you are working for a different platform. For more information about how to use Carthage, please see its project page.

Manually

It is not recommended to install the framework manually, but if you prefer not to use either of the aforementioned dependency managers, you can integrate Kingfisher into your project manually. A regular way to use Kingfisher in your project would be using the Embedded Framework.

  • Add Kingfisher as a submodule. In your favorite terminal, cd into your top-level project directory, and entering the following command:
$ git submodule add https://github.com/onevcat/Kingfisher.git
  • Open the Kingfisher folder, and drag Kingfisher.xcodeproj into the file navigator of your app project, under your app project.
  • In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar.
  • In the tab bar at the top of that window, open the "Build Phases" panel.
  • Expand the "Target Dependencies" group, and add Kingfisher.framework.
  • Click on the + button at the top left of "Build Phases" panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add Kingfisher.framework of the platform you need.

Next

After installation, you could import Kingfisher to your project by adding this:

import Kingfisher

to the files in which you want to use Kingfisher.

Once you prepared, continue to have a look at the Cheat Sheet to see how to use Kingfisher.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.