Presentation is loading. Please wait.

Presentation is loading. Please wait.

Carthage ios 8 onwards Dependency manager that streamlines the process of integrating the libraries into the project.

Similar presentations


Presentation on theme: "Carthage ios 8 onwards Dependency manager that streamlines the process of integrating the libraries into the project."— Presentation transcript:

1 Carthage ios 8 onwards Dependency manager that streamlines the process of integrating the libraries into the project

2 Why Carthage? Standardize the process of fetching third party code and incorporating it into your project Without such a tool, this might be done by manually copying source code files, dropping in precompiled binaries It make easier to update third party libraries in the future. Imagine having to visit each dependency’s GitHub page, download the source, and place it into your project every time there’s an update. They pick out appropriate and compatible versions of each dependency in use. For instance, if you’re manually adding dependencies, things can get tricky when they depend on one another or share another dependency.

3 Carthage Vs CocoaPods When adding “pods” to a project, CocoaPods creates a new Xcode project with a target for each individual pod, as well as a containing workspace. Then you have to use the workspace and trust that the CocoaPods project works correctly. Talk about a lot of extra build settings to maintain. While carthage creates a .framework file which can be used in multiple project. CocoaPods’ Podspecs repository is centralized, which could be problematic if for some reason it were to disappear or become inaccessible.

4 Carthage : A Simple Tool
Carthage doesn’t modify your Xcode project or force you to use a workspace. There’s no need for Podspecs or a centralized repository for library authors to submit their pods to. If your project can be built as a framework, it can be used with Carthage. Add dependencies to your Xcode project manually and Carthage fetches and builds them.

5 Installing Carthage There are two ways to install it
Downloading and running a .pkg installer Or using the Homebrew package manager Here I am using first option Step 1) Download latest version of carthage.pkg from this Link : Step 2) Double-click Carthage.pkg to run the installer Step 3) To check the version of the Carthage open terminal and run the following command carthage version

6 Cartfile Cartfile is a simple text file that describes the project’s dependencies to Carthage Steps : Open terminal go to your project folder run command touch cartfile (your cartfile gets created ) Open cartfile in any text editor you have Add libraries detail and dependency you want for your project eg. github "Alamofire/Alamofire" == 2.0 github "SwiftyJSON/SwiftyJSON" ~> 2.3.0 github : Dependency origin Alamofire/Alamofire : Username/ProjectName == 2.0 : Dependency Version

7 Decide Dependency Version ?
== 1.0 means “Use exactly version 1.0” >= 1.0 means “Use version 1.0 or higher” ~> 1.0 means “Use any version that’s compatible with 1.0″, essentially meaning any version up until the next major release.

8 Building Dependencies
Run the following command to build carthage update --platform iOS This instructs Carthage to clone the Git repositories that are specified in the Cartfile, and then build each dependency into a framework. You will see process similar to below in your terminal Note : --platform iOS option ensures that frameworks are only built for iOS. If platform not specified, then by default Carthage will build frameworks for all platforms (often both Mac and iOS) supported by the library.

9 Run below command to open carthage location

10 Run carthage update, Carthage creates a couple of files and directories
Cartfile.resolved: This file is created to serve as a companion to the Cartfile. It defines exactly which versions of your dependencies Carthage selected for installation. Carthage directory, containing two subdirectories: Build: This contains the built framework for each dependency. These can be integrated into your project Checkouts: This is where Carthage checks out the source code for each dependency that’s ready to build into frameworks. Carthage maintains its own internal cache of dependency repositories, so it doesn’t have to clone the same source multiple times for different projects.

11 Adding Framework To The Project
Select the project target, choose the General tab at the top, and scroll down to the Linked Frameworks and Libraries section at the bottom In the Carthage Finder window, navigate into Build\iOS drag *.framework into the Linked Frameworks and Libraries section in Xcode switch over to Build Phases and add a new Run Script build phase add following commands /usr/local/bin/carthage copy-frameworks Click the + under Input Files and add an entry for each framework as below $(SRCROOT)/Carthage/Build/iOS/Alamofire.framework

12 That’s all and now use framework as usual

13 Thank you


Download ppt "Carthage ios 8 onwards Dependency manager that streamlines the process of integrating the libraries into the project."

Similar presentations


Ads by Google