Installation Guide - qingkong1998/qingkong GitHub Wiki
Everything has a beginning. For using a framework, it's installation.
Versions
Kingfisher supports only Swift 4 from version 4.0. If you are finding a Kingfisher version compatible with Swift 3.2 and prior, choose Kingfisher 3.13.x instead. See the release page to find the version 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, '8.0'
use_frameworks!
target 'MyApp' do
# your other pod
# ...
pod 'Kingfisher', '~> 4.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" ~> 4.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.
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.
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
and add the paths to the frameworks you want to use under “Input Files”:
$(SRCROOT)/Carthage/Build/iOS/Kingfisher.framework
For more information about how to use Carthage, please see its project page.
Swift Package Manager
Swift Package Manager might be also your choice for package management. Just add the url of this repo to your Package.swift file as a dependency:
import PackageDescription
let package = Package(
name: "YourAwesomeSoftware",
dependencies: [
.Package(url: "https://github.com/onevcat/Kingfisher.git",
majorVersion: 4)
]
)
Then run swift build whenever you get prepared.
You could know more information on how to use Swift Package Manager in Apple's official 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 Embedded Framework.
- Add Kingfisher as a submodule. In your favorite terminal,
cdinto your top-level project directory, and entering the following command:
$ git submodule add https://github.com/onevcat/Kingfisher.git
- Open the
Kingfisherfolder, and dragKingfisher.xcodeprojinto 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 addKingfisher.frameworkof 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 this framework.
Once you prepared, continue to have a look at the Cheat Sheet to see how to use Kingfisher.