What is Dependency Management?
When working in iOS, there are plenty of amazing third party libraries that we can use
to save us time and energy in our mobile app development. Third party libraries can
provide useful functions, methods, or templates and can assist in networking, parsing
data, interfacing with Core managerData, fetching web images, and many other
common tasks. These third party libraries are known as dependencies. One way to
obtain and keep these libraries up to date is through a dependency.
Most dependency managers will download your desired third party libraries,
prepare them for your project, and obtain any other required dependencies. A good
dependency manager will keep your libraries up to date and functional.
Threre are plenty of third party libraries which are useful. These libraries kept on
dependancy managers. Each dependency management software has its own set of
benefits and drawbacks.
There are different dependancy manager in iOS which are used in XCode like
CocoaPods, Carthage.
We Learn there two dependancy manager in detail.
1. What is Carthage :
One of best parts of Carthage is that, from the ground up, it is made to be ruthlessly
simple. It was created by developers from GitHub, and was written entirely in Swift. In
fact, it was the first dependency manager to officially support Swift.
Steps to install Carthage :-
1. The "Carthage.pkg" can be downloaded from
"https://github.com/Carthage/Carthage/releases" link
2. once you downloaded it from github. open it by double clicking. and if it gives error
like "carthage.pkg cant opened because of unidentifier developer". Then control and
click to open the file and then install.
If you want to add third party libraries or dependencies then follow the steps:
1. Create the xcode project
2. open terminal and give path of the folder of created project
3. you can check the carthage version using terminal command like i.e carthage
version
4.Create an empty cartfile by using terminal command like i.e. touch Cartfile
5. open cartfile manually or using terminal command like i.e. open -a Xcode Cartfile
6. enter the following to tell Carthage which dependencies we want like i.e. github
"Alamofire/Alamofire" ~> 3.3
7. close your cartfile and run command like i.e. carthage update --platform iOS
8. open carthage manually or using terminal command like i.e. open Carthage
9. open the xcode project and in General section go to the Linked Frameworks &
Libraries and drag and drop frameworks from carthage.
10. In Project Setting go on Build Phases and Add a “New Copy Files Phase”
11. Go down to the “Copy Files” section. Under “Destination” select “Frameworks”.
12. Add the frameworks.
import the libraries where you want to use.
2. CocoaPods
CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has
over 30 thousand libraries and is used in over 1.9 million apps. CocoaPods can help
you scale your projects elegantly.
1. You first need to install CocoaPods. Fortunately, CocoaPods is built on Ruby.
Open Terminal and enter the following command:
sudo gem install cocoapods
Enter your password when requested
2.Open Terminal and navigate to the directory that contains your contains project by
using the cd command
cd ~/Path/To/Folder/Containing/projectName
3. enter the next comand to create podfile within your project.
pod init
4. open podfile manually or using terminal command
open -a Xcode Podfile
5. add dependency after use_Frameworks in your podfile like
pod 'Alamofire', '4.4.0'
6. install dependencies using following command in your project
pod 'Alamofire', '4.4.0'
7. use .xcworkspace
When working in iOS, there are plenty of amazing third party libraries that we can use
to save us time and energy in our mobile app development. Third party libraries can
provide useful functions, methods, or templates and can assist in networking, parsing
data, interfacing with Core managerData, fetching web images, and many other
common tasks. These third party libraries are known as dependencies. One way to
obtain and keep these libraries up to date is through a dependency.
Most dependency managers will download your desired third party libraries,
prepare them for your project, and obtain any other required dependencies. A good
dependency manager will keep your libraries up to date and functional.
Threre are plenty of third party libraries which are useful. These libraries kept on
dependancy managers. Each dependency management software has its own set of
benefits and drawbacks.
There are different dependancy manager in iOS which are used in XCode like
CocoaPods, Carthage.
We Learn there two dependancy manager in detail.
1. What is Carthage :
One of best parts of Carthage is that, from the ground up, it is made to be ruthlessly
simple. It was created by developers from GitHub, and was written entirely in Swift. In
fact, it was the first dependency manager to officially support Swift.
Steps to install Carthage :-
1. The "Carthage.pkg" can be downloaded from
"https://github.com/Carthage/Carthage/releases" link
2. once you downloaded it from github. open it by double clicking. and if it gives error
like "carthage.pkg cant opened because of unidentifier developer". Then control and
click to open the file and then install.
If you want to add third party libraries or dependencies then follow the steps:
1. Create the xcode project
2. open terminal and give path of the folder of created project
3. you can check the carthage version using terminal command like i.e carthage
version
4.Create an empty cartfile by using terminal command like i.e. touch Cartfile
5. open cartfile manually or using terminal command like i.e. open -a Xcode Cartfile
6. enter the following to tell Carthage which dependencies we want like i.e. github
"Alamofire/Alamofire" ~> 3.3
7. close your cartfile and run command like i.e. carthage update --platform iOS
8. open carthage manually or using terminal command like i.e. open Carthage
9. open the xcode project and in General section go to the Linked Frameworks &
Libraries and drag and drop frameworks from carthage.
10. In Project Setting go on Build Phases and Add a “New Copy Files Phase”
11. Go down to the “Copy Files” section. Under “Destination” select “Frameworks”.
12. Add the frameworks.
import the libraries where you want to use.
2. CocoaPods
CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has
over 30 thousand libraries and is used in over 1.9 million apps. CocoaPods can help
you scale your projects elegantly.
1. You first need to install CocoaPods. Fortunately, CocoaPods is built on Ruby.
Open Terminal and enter the following command:
sudo gem install cocoapods
Enter your password when requested
2.Open Terminal and navigate to the directory that contains your contains project by
using the cd command
cd ~/Path/To/Folder/Containing/projectName
3. enter the next comand to create podfile within your project.
pod init
4. open podfile manually or using terminal command
open -a Xcode Podfile
5. add dependency after use_Frameworks in your podfile like
pod 'Alamofire', '4.4.0'
6. install dependencies using following command in your project
pod 'Alamofire', '4.4.0'
7. use .xcworkspace