Mobile Development: Cocoapods
In this post you will find how to setup Cocoapods into your Objective-C application project.
Cocoapods
Cocoapods is an open-source dependency manager for Objective-C applications. By using Cocoapods you can find and use many usefull libraries that will help you in making a great apps.
Installation
Cocoapods is written in Ruby. To install Cocoapods, you can simply run:
Setup project
After creating your Objective-C project, in your project directory you can run:
That command will create file named Podfile. You can specify your dependencies in that file. Then run this command to setup your project and install the dependencies.
Now you should open <your-project-name>.xworkspace
to open your project.
Search dependencies
To search a dependency you can go to Cocoapods, or run:
Add dependencies
You should add your dependency into Podfile
.
After that run:
By running that command cocoapods will install:
AFNetworking
with version2.0
Facebook-iOS-SDK
with version3.10.0
or version up to3.11
not3.11
or higheryour-dependency
with lastest version
Notice that in Podfile
you can specify the version of a dependency you use.
The other ways to specify dependency version:
'~> 2.0'
means version2.0
and version up to3.0
not including3.0
or higher'> 2.0'
means any version higher than2.0
'>= 2.0'
means any version higher than2.0
including2.0
'< 2.0'
means any version lower than2.0
'<= 2.0'
means any version lower than2.0
including2.0
'2.0'
means version2.0
- leave blank means latest version
Conclusion
- Install Cocoapods
- Find libraries/dependencies that suit your needs
- Tell Cocoapods to install your dependencies
- Have fun