Installation and Use of Carthage, and installation and use of Carthage
Compared with Cocoapods, Cocoapods has its own advantages and disadvantages. For more information, see:
Carthage: four advantages and four disadvantages
Step 1: Install Homebrew first
Open the command terminal and enter the following command and press Enter.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
In this way, it will be installed on its own, during which you will be asked to enter the Local Password
Step 2: Install Carthage
On the command terminal, enter the following command and press Enter.
$ brew update$ brew install carthage
View version commands after installation
$ carthage version
Step 3: Use Carthage
1. Enter the project folder through the terminal:
$ cd /Users/cdmac/Desktop/Demos/DemoX8
2. Create an empty carthage file:
$ touch Cartfile
3. Use xcode to open the cartfile File
$ open -a Xcode Cartfile
Add the following content to the opened file:
github "Alamofire/Alamofire" ~> 4.0github "SwiftyJSON/SwiftyJSON"
Version description:
~> 3.0 indicates that the latest version is later than version 3.0 but earlier than version 4.0, such as 3.5, 3.9
= 3.0 indicates that version 3.0 is used.
> = 3.0 indicates that version 3.0 or later is used.
If you do not specify a version number, the latest version is automatically used.
4. Save and close the cart file and run the command on the terminal.
$ carthage update --platform iOS
Carthage will download and compile the required third-party library for you. After the command is executed, a folder named Carthage will be created in your project folder.
The xxx. framework file has been created for you in/Users/cdmac/Desktop/Demos/DemoX8/Carthage/Build/iOS.
Of course, you can also enter this folder through the command line:
$ open Carthage
5. Open your project now, click project, select target, and then select General at the top. Drag the required framework file to Linked frameworks and Binaries.
6. Click the Build Phrase tab option to add the corresponding run script.
References:
Homebrew installation tutorial
How to Use Carthage-support Carthage for your project
How to Use Carthage to manage iOS dependent Libraries