SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Milan Panchal
iOS Developer
B L O G : h t t p : / / w w w . j e e n a l i n f o t e c h . c o m /
iOS - Cocoa Pods
1
Cocoa Pods By Milan Panchal
Agenda
 What is CocoaPods?
 Why use CocoaPods?
 Installing CocoaPods
 Using CocoaPods in a project
 CocoaPods Versioning
 CocoaPods and source control
 What is Podfile.lock?
 Other
2
Cocoa Pods By Milan Panchal
What is CocoaPods?
3
 CocoaPods is a dependency management tool for
iOS (Objective-C/Swift) and OS X development.
Eg. Maven for Java Projects.
 It is built with Ruby so we can install through
default Ruby available on OS X.
 It has thousands of libraries and can help you scale
your projects elegantly.
Cocoa Pods By Milan Panchal
Why we use CocoaPods?
4
 You begin working on a project and everything is going
great. As the project progresses, you find it necessary
to use third party libraries to help the project move
along faster.
 You do this by searching for appropriate libraries and
copying the source code into your project.
 When a library is updated, you manually update it in
your project. At times, a library might break your
build, forcing you to revert back to a compatible
version.
Cocoa Pods By Milan Panchal
Why we use CocoaPods? (Continue.)
5
 You have to search for it and copy it into your
project. Add more libraries and you start noticing the
time drain that maintaining your project
dependencies is.
 You are also bound to encounter situations where a
library you want to use depends on another library
and you will have to get them both.
 If you use multiple libraries sharing a dependency,
but all specify a different version of the dependency,
you’ll have to figure out what the best version of the
library is that will satisfy all dependencies.
Cocoa Pods By Milan Panchal
Why we use CocoaPods? (Continue.)
6
 As your project scales, you’ll be spending a lot of time
managing its dependencies, time that could be better
used writing code.
 CocoaPods make managing dependencies in your code
easier. Adding and removing dependencies is just a
matter of defining them in a file and running a command
to install them.
 CocoaPods reads the file, determines the dependencies
that the listed libraries have and if there are any shared
dependencies, it tries to determine the version that will
satisfy all of them. It uses Semantic Versioning to try to
resolve dependency versions.
Cocoa Pods By Milan Panchal
Installing CocoaPods
7
 CocoaPods is distributed as a Ruby gem and so will
require Ruby and RubyGems (the Ruby package
manager) to be installed on your system.
 To check whether Ruby is installed, run the ruby -v
command in the Terminal.
 Before installing CocoaPods, first update your
RubyGems.
$ [sudo] gem update --system
 To install CocoaPods, run the following command.
$ [sudo] gem install cocoapods
Cocoa Pods By Milan Panchal
Installing CocoaPods (Continue)
8
 Next run the following to setup CocoaPods on you
system.
$ pod setup [--verbose]
 This will create a ~/.cocoapods/ directory which will
contain all the available public pod specifications
cloned from the CocoaPods Master Specs Repo.
 This process will likely take a few minutes as it clones
the CocoaPods Master Specs repository into
~/.cocoapods/ on your computer.
Cocoa Pods By Milan Panchal
Installing CocoaPods (Continue)
9
 The verbose option logs progress as the process
runs, allowing you to watch the process instead of
seeing a seemingly “frozen” screen.
 Now we are all set up and ready to use CocoaPods
in our project. 
Cocoa Pods By Milan Panchal
Using CocoaPods (Continue)
10
 To create the Podfile, using Terminal, navigate to the
root of the app you created.
$ cd /Path/to/Project/TestApp
 Run the following command, which will create a
Podfile at the specified file path.
$ pod init
 Type this command to open the Podfile using Xcode
for editing:
$ open -a Xcode Podfile
Cocoa Pods By Milan Panchal
Using CocoaPods (Continue)
11
The default Podfile looks like this:
# Uncomment this line to define a global platform for your project
# platform :ios, "8.0”
target "TestApp" do
pod 'iOS-Category'
pod 'iOS-Category', '~> 1.0.4’
end
target "TestAppTests" do
end
Cocoa Pods By Milan Panchal
Using CocoaPods (Continue)
12
 The platform can be either ios or osx.
 Add a CocoaPod by specifying pod
'$PODNAME' on a single line
 After editing the Podfile, save it and run
the following command.
$ pod install
Cocoa Pods By Milan Panchal
Using CocoaPods (Continue)
13
Inhibits all the warnings from the CocoaPods libraries.
Add the following to the top of Podfile to tell CocoaPods
to silence all warnings from pod dependencies:
$ inhibit_all_warnings!
If you would like to inhibit warnings per Pod you can
use the following syntax:
$ pod 'iOS-Category', :inhibit_warnings => true
Cocoa Pods By Milan Panchal
Using CocoaPods (Continue)
14
 use_frameworks!
platform :ios, "8.0"
use_frameworks!
 This tells CocoaPods that your project is targeting
iOS 8.0 and will be using frameworks instead of
static libraries.
Cocoa Pods By Milan Panchal
Using CocoaPods (Continue)
15
 generate_bridge_support!
 Specifies that a BridgeSupport metadata document
should be generated from the headers of all
installed Pods.
 set_arc_compatibility_flag!
 Specifies that the -fobjc-arc flag should be added to
the OTHER_LD_FLAGS.
Cocoa Pods By Milan Panchal
CocoaPods Versioning
16
 CocoaPods follows the Semantic Versioning policy.
You can read more about major, minor and patch
versions at the given link.
 When the version number is not specified, the latest
version of the pod will be fetched.
 You can specify an exact version by including a specific
version number.
 For instance, pod 'iOS-Category', '1.0.4’
Cocoa Pods By Milan Panchal
CocoaPods Versioning (Continue)
17
 Besides no version, or a specific one, it is also
possible to use operators:
• > 0.1 Any version higher than 0.1.
• >= 0.1 Version 0.1 and any higher version.
• < 0.1 Any version lower than 0.1.
• <= 0.1 Version 0.1 and any lower version.
• ~> 0.1.2 Version 0.1.2 and the versions up to 0.2, not
including 0.2. This operator works based on the last
component that you specify in your version requirement.
The example is equal to >= 0.1.2 combined with < 0.2.0
and will always match the latest known version matching
your requirements.
Cocoa Pods By Milan Panchal
Pods and Source Control
18
 There are various arguments on what CocoaPods
files should go under version control. This is
simply a matter of preference.
 There is a list of pros and cons of adding the Pods
folder in your .gitignore file.
 You should however keep the Podfile.lock under
version control. This is the file that keeps track of
what version of a Pod is installed.
Cocoa Pods By Milan Panchal
Pods and Source Control (Continue)
19
Benefits of ignoring the Pods directory
 The source control repo will be smaller and take up less space.
 As long as the sources (e.g. GitHub) for all Pods are available,
CocoaPods is generally able to recreate the same installation.
(Technically there is no guarantee that running pod install will
fetch and recreate identical artifacts when not using a commit
SHA in the Podfile. This is especially true when using zip files in
the Podfile.)
 There won't be any conflicts to deal with when performing source
control operations, such as merging branches with different Pod
versions.
 Whether or not you check in the Pods directory, the Podfile and
Podfile.lock should always be kept under version control.
Cocoa Pods By Milan Panchal
Pods and Source Control (Continue)
20
Benefits of checking in the Pods directory
• After cloning the repo, the project can immediately build
and run, even without having CocoaPods installed on the
machine.
• There is no need to run pod install, and no Internet
connection is necessary.
• The Pod artifacts (code/libraries) are always available,
even if the source of a Pod (e.g. GitHub) were to go down.
• The Pod artifacts are guaranteed to be identical to those in
the original installation after cloning the repo.x
Cocoa Pods By Milan Panchal
What is Podfile.lock?
21
 This file is generated after the first run of pod install,
and tracks the version of each Pod that was installed.
 For example, imagine the following dependency
specified in the Podfile:
pod 'iOS-Category'
 Running pod install will install the current version of
iOS-Category, causing a Podfile.lock to be generated
that indicates the exact version installed (e.g. iOS-
Category 1.0.5).
Cocoa Pods By Milan Panchal
What is Podfile.lock? (Continue)
22
 Thanks to the Podfile.lock, running pod install on this
hypothetical project at a later point in time on a
different machine will still install iOS-Category 1.0.5
even if a newer version is available. CocoaPods will
honour the Pod version in Podfile.lock unless the
dependency is updated in the Podfile or pod update is
called (which will cause a new Podfile.lock to be
generated). In this way CocoaPods avoids headaches
caused by unexpected changes to dependencies.
 This file should always be kept under version control.
Cocoa Pods By Milan Panchal
Other
23
Using the files from a local path or repo (GIT/SVN)
 From Local Machine:
pod 'ExamplePod', :path => '~/Documents/ExamplePod'
 From a git repository:
 To use the master branch of the repository:
pod 'ExamplePod', :git => 'https://github.com/eguser/ExamplePod.git'
 To use a different branch of the repository:
pod 'ExamplePod', :git => 'https://github.com/eguser/ExamplePod.git', :branch => 'dev'
 To use a tag of the repository:
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :tag => '0.7.0'
 Or specify a commit:
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :commit =>
'082f8319af’
Cocoa Pods By Milan Panchal
Other (Continue)
24
 Trying Out Pods
 CocoaPods has a feature that enables you to
download and try out a library before you use it in
your project. It downloads the demo project of a
Pod and opens it in Xcode.
 Use the pod try [LIB_NAME] command to try out
a Pod.
pod try iOS-Category
Cocoa Pods By Milan Panchal
Other (Continue)
25
Installing The Same Pod In Multiple Targets
The Ugly But Works Solution
# Podfile
platform :ios, ‘8.0’
use_frameworks!
# My other pods
target 'MyTests' do
pod 'Quick', '0.5.0'
pod 'Nimble', '2.0.0-rc.1'
end
target 'MyUITests' do
pod 'Quick', '0.5.0'
pod 'Nimble', '2.0.0-rc.1'
end
Cocoa Pods By Milan Panchal
Other (Continue)
26
Installing The Same Pod In Multiple Targets
The Elegant Solution
platform :ios, ‘8.0’
use_frameworks!
# My other pods
def testing_pods
pod 'Quick', '0.5.0’
pod 'Nimble', '2.0.0-rc.1’
end
target 'MyTests' do
testing_pods
end
target 'MyUITests' do
testing_pods
end
Cocoa Pods By Milan Panchal
Other (Continue)
27
 Semantic Versioning:
• A normal version number MUST take the form
X.Y.Z where X, Y, and Z are non-negative integers,
and MUST NOT contain leading zeroes. X is the
major version, Y is the minor version, and Z is the
patch version. Each element MUST increase
numerically. For instance: 1.9.0 -> 1.10.0 -> 1.11.0
Cocoa Pods By Milan Panchal
28
Thank You
Cocoa Pods By Milan Panchal

Weitere ähnliche Inhalte

Was ist angesagt?

Microservices with Kubernetes, Docker, and Jenkins
Microservices with Kubernetes, Docker, and JenkinsMicroservices with Kubernetes, Docker, and Jenkins
Microservices with Kubernetes, Docker, and JenkinsRafael Benevides
 
Voxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as code
Voxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as codeVoxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as code
Voxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as codeDamien Duportal
 
WebCenter Portal - Integrate Custom taskflows
WebCenter Portal - Integrate Custom taskflowsWebCenter Portal - Integrate Custom taskflows
WebCenter Portal - Integrate Custom taskflowsenpit GmbH & Co. KG
 
Cooking the Cake for Nuget packages
Cooking the Cake for Nuget packagesCooking the Cake for Nuget packages
Cooking the Cake for Nuget packagesSergey Dzyuban
 
[WroclawJUG] Continuous Delivery in OSS using Shipkit
[WroclawJUG] Continuous Delivery in OSS using Shipkit[WroclawJUG] Continuous Delivery in OSS using Shipkit
[WroclawJUG] Continuous Delivery in OSS using ShipkitMarcinStachniuk
 
OSDC 2017 - Julien Pivotto - Automating Jenkins
OSDC 2017 - Julien Pivotto - Automating JenkinsOSDC 2017 - Julien Pivotto - Automating Jenkins
OSDC 2017 - Julien Pivotto - Automating JenkinsNETWAYS
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins PipelinesSteffen Gebert
 
Hudson@java one2010
Hudson@java one2010Hudson@java one2010
Hudson@java one2010InfraDNA
 
Apache Flink Crash Course by Slim Baltagi and Srini Palthepu
Apache Flink Crash Course by Slim Baltagi and Srini PalthepuApache Flink Crash Course by Slim Baltagi and Srini Palthepu
Apache Flink Crash Course by Slim Baltagi and Srini PalthepuSlim Baltagi
 
Docker for (Java) Developers
Docker for (Java) DevelopersDocker for (Java) Developers
Docker for (Java) DevelopersRafael Benevides
 
OpenShift-Build-Pipelines: Build -> Test -> Run! @JavaForumStuttgart
OpenShift-Build-Pipelines: Build -> Test -> Run! @JavaForumStuttgartOpenShift-Build-Pipelines: Build -> Test -> Run! @JavaForumStuttgart
OpenShift-Build-Pipelines: Build -> Test -> Run! @JavaForumStuttgartTobias Schneck
 
Gitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTreeGitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTreeTeerapat Khunpech
 
Jenkins Shared Libraries Workshop
Jenkins Shared Libraries WorkshopJenkins Shared Libraries Workshop
Jenkins Shared Libraries WorkshopJulien Pivotto
 
Codifying the Build and Release Process with a Jenkins Pipeline Shared Library
Codifying the Build and Release Process with a Jenkins Pipeline Shared LibraryCodifying the Build and Release Process with a Jenkins Pipeline Shared Library
Codifying the Build and Release Process with a Jenkins Pipeline Shared LibraryAlvin Huang
 
Open Source tools overview
Open Source tools overviewOpen Source tools overview
Open Source tools overviewLuciano Resende
 
Testing fácil con Docker: Gestiona dependencias y unifica entornos
Testing fácil con Docker: Gestiona dependencias y unifica entornosTesting fácil con Docker: Gestiona dependencias y unifica entornos
Testing fácil con Docker: Gestiona dependencias y unifica entornosMicael Gallego
 
Building kubectl plugins with Quarkus | DevNation Tech Talk
Building kubectl plugins with Quarkus | DevNation Tech TalkBuilding kubectl plugins with Quarkus | DevNation Tech Talk
Building kubectl plugins with Quarkus | DevNation Tech TalkRed Hat Developers
 

Was ist angesagt? (20)

Microservices with Kubernetes, Docker, and Jenkins
Microservices with Kubernetes, Docker, and JenkinsMicroservices with Kubernetes, Docker, and Jenkins
Microservices with Kubernetes, Docker, and Jenkins
 
Voxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as code
Voxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as codeVoxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as code
Voxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as code
 
WebCenter Portal - Integrate Custom taskflows
WebCenter Portal - Integrate Custom taskflowsWebCenter Portal - Integrate Custom taskflows
WebCenter Portal - Integrate Custom taskflows
 
Cooking the Cake for Nuget packages
Cooking the Cake for Nuget packagesCooking the Cake for Nuget packages
Cooking the Cake for Nuget packages
 
[WroclawJUG] Continuous Delivery in OSS using Shipkit
[WroclawJUG] Continuous Delivery in OSS using Shipkit[WroclawJUG] Continuous Delivery in OSS using Shipkit
[WroclawJUG] Continuous Delivery in OSS using Shipkit
 
OSDC 2017 - Julien Pivotto - Automating Jenkins
OSDC 2017 - Julien Pivotto - Automating JenkinsOSDC 2017 - Julien Pivotto - Automating Jenkins
OSDC 2017 - Julien Pivotto - Automating Jenkins
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
 
Hudson@java one2010
Hudson@java one2010Hudson@java one2010
Hudson@java one2010
 
Apache Flink Crash Course by Slim Baltagi and Srini Palthepu
Apache Flink Crash Course by Slim Baltagi and Srini PalthepuApache Flink Crash Course by Slim Baltagi and Srini Palthepu
Apache Flink Crash Course by Slim Baltagi and Srini Palthepu
 
Docker for (Java) Developers
Docker for (Java) DevelopersDocker for (Java) Developers
Docker for (Java) Developers
 
OpenShift-Build-Pipelines: Build -> Test -> Run! @JavaForumStuttgart
OpenShift-Build-Pipelines: Build -> Test -> Run! @JavaForumStuttgartOpenShift-Build-Pipelines: Build -> Test -> Run! @JavaForumStuttgart
OpenShift-Build-Pipelines: Build -> Test -> Run! @JavaForumStuttgart
 
Automating the Quality
Automating the QualityAutomating the Quality
Automating the Quality
 
Gitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTreeGitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTree
 
Jenkins Shared Libraries Workshop
Jenkins Shared Libraries WorkshopJenkins Shared Libraries Workshop
Jenkins Shared Libraries Workshop
 
Versions
VersionsVersions
Versions
 
Codifying the Build and Release Process with a Jenkins Pipeline Shared Library
Codifying the Build and Release Process with a Jenkins Pipeline Shared LibraryCodifying the Build and Release Process with a Jenkins Pipeline Shared Library
Codifying the Build and Release Process with a Jenkins Pipeline Shared Library
 
Open Source tools overview
Open Source tools overviewOpen Source tools overview
Open Source tools overview
 
Testing fácil con Docker: Gestiona dependencias y unifica entornos
Testing fácil con Docker: Gestiona dependencias y unifica entornosTesting fácil con Docker: Gestiona dependencias y unifica entornos
Testing fácil con Docker: Gestiona dependencias y unifica entornos
 
Building kubectl plugins with Quarkus | DevNation Tech Talk
Building kubectl plugins with Quarkus | DevNation Tech TalkBuilding kubectl plugins with Quarkus | DevNation Tech Talk
Building kubectl plugins with Quarkus | DevNation Tech Talk
 

Ähnlich wie What is CocoaPods and how to setup?

Dependent things dependency management for apple sw - slideshare
Dependent things   dependency management for apple sw - slideshareDependent things   dependency management for apple sw - slideshare
Dependent things dependency management for apple sw - slideshareCavelle Benjamin
 
Create Your First Cocoa pods
Create Your First Cocoa podsCreate Your First Cocoa pods
Create Your First Cocoa podsPawan Ramteke
 
Manage your external libraries with CocoaPods
Manage your external libraries with CocoaPodsManage your external libraries with CocoaPods
Manage your external libraries with CocoaPodsJuan C Catalan
 
Building an Ionic hybrid mobile app with TypeScript
Building an Ionic hybrid mobile app with TypeScript Building an Ionic hybrid mobile app with TypeScript
Building an Ionic hybrid mobile app with TypeScript Serge van den Oever
 
Run your Java code on Cloud Foundry
Run your Java code on Cloud FoundryRun your Java code on Cloud Foundry
Run your Java code on Cloud FoundryAndy Piper
 
State ofappdevelopment
State ofappdevelopmentState ofappdevelopment
State ofappdevelopmentgillygize
 
TiConf NYC - Documenting Your Titanium Applications
TiConf NYC - Documenting Your Titanium ApplicationsTiConf NYC - Documenting Your Titanium Applications
TiConf NYC - Documenting Your Titanium ApplicationsJamil Spain
 
Documenting apps ti confnyc
Documenting apps   ti confnycDocumenting apps   ti confnyc
Documenting apps ti confnycJamil Spain
 
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...Andrey Karpov
 
APACHE
APACHEAPACHE
APACHEARJUN
 
Installing spark scala console in windows 10
Installing spark scala console in windows 10Installing spark scala console in windows 10
Installing spark scala console in windows 10Ankit Kaneri
 

Ähnlich wie What is CocoaPods and how to setup? (20)

CocoaPods.pptx
CocoaPods.pptxCocoaPods.pptx
CocoaPods.pptx
 
Private pod support using cocoa pods in ios
Private pod support using cocoa pods in iosPrivate pod support using cocoa pods in ios
Private pod support using cocoa pods in ios
 
Cocoapods
CocoapodsCocoapods
Cocoapods
 
Dependent things dependency management for apple sw - slideshare
Dependent things   dependency management for apple sw - slideshareDependent things   dependency management for apple sw - slideshare
Dependent things dependency management for apple sw - slideshare
 
Using Cocoapods
Using CocoapodsUsing Cocoapods
Using Cocoapods
 
Create Your First Cocoa pods
Create Your First Cocoa podsCreate Your First Cocoa pods
Create Your First Cocoa pods
 
Manage your external libraries with CocoaPods
Manage your external libraries with CocoaPodsManage your external libraries with CocoaPods
Manage your external libraries with CocoaPods
 
Creating Cocoapods Library
Creating Cocoapods LibraryCreating Cocoapods Library
Creating Cocoapods Library
 
Building an Ionic hybrid mobile app with TypeScript
Building an Ionic hybrid mobile app with TypeScript Building an Ionic hybrid mobile app with TypeScript
Building an Ionic hybrid mobile app with TypeScript
 
Run your Java code on Cloud Foundry
Run your Java code on Cloud FoundryRun your Java code on Cloud Foundry
Run your Java code on Cloud Foundry
 
Flask
FlaskFlask
Flask
 
Appsody
AppsodyAppsody
Appsody
 
State ofappdevelopment
State ofappdevelopmentState ofappdevelopment
State ofappdevelopment
 
TiConf NYC - Documenting Your Titanium Applications
TiConf NYC - Documenting Your Titanium ApplicationsTiConf NYC - Documenting Your Titanium Applications
TiConf NYC - Documenting Your Titanium Applications
 
Documenting apps ti confnyc
Documenting apps   ti confnycDocumenting apps   ti confnyc
Documenting apps ti confnyc
 
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
 
PaaSing Your Code Around
PaaSing Your Code AroundPaaSing Your Code Around
PaaSing Your Code Around
 
JAVA First Day
JAVA First DayJAVA First Day
JAVA First Day
 
APACHE
APACHEAPACHE
APACHE
 
Installing spark scala console in windows 10
Installing spark scala console in windows 10Installing spark scala console in windows 10
Installing spark scala console in windows 10
 

Kürzlich hochgeladen

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 

Kürzlich hochgeladen (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

What is CocoaPods and how to setup?

  • 1. Milan Panchal iOS Developer B L O G : h t t p : / / w w w . j e e n a l i n f o t e c h . c o m / iOS - Cocoa Pods 1 Cocoa Pods By Milan Panchal
  • 2. Agenda  What is CocoaPods?  Why use CocoaPods?  Installing CocoaPods  Using CocoaPods in a project  CocoaPods Versioning  CocoaPods and source control  What is Podfile.lock?  Other 2 Cocoa Pods By Milan Panchal
  • 3. What is CocoaPods? 3  CocoaPods is a dependency management tool for iOS (Objective-C/Swift) and OS X development. Eg. Maven for Java Projects.  It is built with Ruby so we can install through default Ruby available on OS X.  It has thousands of libraries and can help you scale your projects elegantly. Cocoa Pods By Milan Panchal
  • 4. Why we use CocoaPods? 4  You begin working on a project and everything is going great. As the project progresses, you find it necessary to use third party libraries to help the project move along faster.  You do this by searching for appropriate libraries and copying the source code into your project.  When a library is updated, you manually update it in your project. At times, a library might break your build, forcing you to revert back to a compatible version. Cocoa Pods By Milan Panchal
  • 5. Why we use CocoaPods? (Continue.) 5  You have to search for it and copy it into your project. Add more libraries and you start noticing the time drain that maintaining your project dependencies is.  You are also bound to encounter situations where a library you want to use depends on another library and you will have to get them both.  If you use multiple libraries sharing a dependency, but all specify a different version of the dependency, you’ll have to figure out what the best version of the library is that will satisfy all dependencies. Cocoa Pods By Milan Panchal
  • 6. Why we use CocoaPods? (Continue.) 6  As your project scales, you’ll be spending a lot of time managing its dependencies, time that could be better used writing code.  CocoaPods make managing dependencies in your code easier. Adding and removing dependencies is just a matter of defining them in a file and running a command to install them.  CocoaPods reads the file, determines the dependencies that the listed libraries have and if there are any shared dependencies, it tries to determine the version that will satisfy all of them. It uses Semantic Versioning to try to resolve dependency versions. Cocoa Pods By Milan Panchal
  • 7. Installing CocoaPods 7  CocoaPods is distributed as a Ruby gem and so will require Ruby and RubyGems (the Ruby package manager) to be installed on your system.  To check whether Ruby is installed, run the ruby -v command in the Terminal.  Before installing CocoaPods, first update your RubyGems. $ [sudo] gem update --system  To install CocoaPods, run the following command. $ [sudo] gem install cocoapods Cocoa Pods By Milan Panchal
  • 8. Installing CocoaPods (Continue) 8  Next run the following to setup CocoaPods on you system. $ pod setup [--verbose]  This will create a ~/.cocoapods/ directory which will contain all the available public pod specifications cloned from the CocoaPods Master Specs Repo.  This process will likely take a few minutes as it clones the CocoaPods Master Specs repository into ~/.cocoapods/ on your computer. Cocoa Pods By Milan Panchal
  • 9. Installing CocoaPods (Continue) 9  The verbose option logs progress as the process runs, allowing you to watch the process instead of seeing a seemingly “frozen” screen.  Now we are all set up and ready to use CocoaPods in our project.  Cocoa Pods By Milan Panchal
  • 10. Using CocoaPods (Continue) 10  To create the Podfile, using Terminal, navigate to the root of the app you created. $ cd /Path/to/Project/TestApp  Run the following command, which will create a Podfile at the specified file path. $ pod init  Type this command to open the Podfile using Xcode for editing: $ open -a Xcode Podfile Cocoa Pods By Milan Panchal
  • 11. Using CocoaPods (Continue) 11 The default Podfile looks like this: # Uncomment this line to define a global platform for your project # platform :ios, "8.0” target "TestApp" do pod 'iOS-Category' pod 'iOS-Category', '~> 1.0.4’ end target "TestAppTests" do end Cocoa Pods By Milan Panchal
  • 12. Using CocoaPods (Continue) 12  The platform can be either ios or osx.  Add a CocoaPod by specifying pod '$PODNAME' on a single line  After editing the Podfile, save it and run the following command. $ pod install Cocoa Pods By Milan Panchal
  • 13. Using CocoaPods (Continue) 13 Inhibits all the warnings from the CocoaPods libraries. Add the following to the top of Podfile to tell CocoaPods to silence all warnings from pod dependencies: $ inhibit_all_warnings! If you would like to inhibit warnings per Pod you can use the following syntax: $ pod 'iOS-Category', :inhibit_warnings => true Cocoa Pods By Milan Panchal
  • 14. Using CocoaPods (Continue) 14  use_frameworks! platform :ios, "8.0" use_frameworks!  This tells CocoaPods that your project is targeting iOS 8.0 and will be using frameworks instead of static libraries. Cocoa Pods By Milan Panchal
  • 15. Using CocoaPods (Continue) 15  generate_bridge_support!  Specifies that a BridgeSupport metadata document should be generated from the headers of all installed Pods.  set_arc_compatibility_flag!  Specifies that the -fobjc-arc flag should be added to the OTHER_LD_FLAGS. Cocoa Pods By Milan Panchal
  • 16. CocoaPods Versioning 16  CocoaPods follows the Semantic Versioning policy. You can read more about major, minor and patch versions at the given link.  When the version number is not specified, the latest version of the pod will be fetched.  You can specify an exact version by including a specific version number.  For instance, pod 'iOS-Category', '1.0.4’ Cocoa Pods By Milan Panchal
  • 17. CocoaPods Versioning (Continue) 17  Besides no version, or a specific one, it is also possible to use operators: • > 0.1 Any version higher than 0.1. • >= 0.1 Version 0.1 and any higher version. • < 0.1 Any version lower than 0.1. • <= 0.1 Version 0.1 and any lower version. • ~> 0.1.2 Version 0.1.2 and the versions up to 0.2, not including 0.2. This operator works based on the last component that you specify in your version requirement. The example is equal to >= 0.1.2 combined with < 0.2.0 and will always match the latest known version matching your requirements. Cocoa Pods By Milan Panchal
  • 18. Pods and Source Control 18  There are various arguments on what CocoaPods files should go under version control. This is simply a matter of preference.  There is a list of pros and cons of adding the Pods folder in your .gitignore file.  You should however keep the Podfile.lock under version control. This is the file that keeps track of what version of a Pod is installed. Cocoa Pods By Milan Panchal
  • 19. Pods and Source Control (Continue) 19 Benefits of ignoring the Pods directory  The source control repo will be smaller and take up less space.  As long as the sources (e.g. GitHub) for all Pods are available, CocoaPods is generally able to recreate the same installation. (Technically there is no guarantee that running pod install will fetch and recreate identical artifacts when not using a commit SHA in the Podfile. This is especially true when using zip files in the Podfile.)  There won't be any conflicts to deal with when performing source control operations, such as merging branches with different Pod versions.  Whether or not you check in the Pods directory, the Podfile and Podfile.lock should always be kept under version control. Cocoa Pods By Milan Panchal
  • 20. Pods and Source Control (Continue) 20 Benefits of checking in the Pods directory • After cloning the repo, the project can immediately build and run, even without having CocoaPods installed on the machine. • There is no need to run pod install, and no Internet connection is necessary. • The Pod artifacts (code/libraries) are always available, even if the source of a Pod (e.g. GitHub) were to go down. • The Pod artifacts are guaranteed to be identical to those in the original installation after cloning the repo.x Cocoa Pods By Milan Panchal
  • 21. What is Podfile.lock? 21  This file is generated after the first run of pod install, and tracks the version of each Pod that was installed.  For example, imagine the following dependency specified in the Podfile: pod 'iOS-Category'  Running pod install will install the current version of iOS-Category, causing a Podfile.lock to be generated that indicates the exact version installed (e.g. iOS- Category 1.0.5). Cocoa Pods By Milan Panchal
  • 22. What is Podfile.lock? (Continue) 22  Thanks to the Podfile.lock, running pod install on this hypothetical project at a later point in time on a different machine will still install iOS-Category 1.0.5 even if a newer version is available. CocoaPods will honour the Pod version in Podfile.lock unless the dependency is updated in the Podfile or pod update is called (which will cause a new Podfile.lock to be generated). In this way CocoaPods avoids headaches caused by unexpected changes to dependencies.  This file should always be kept under version control. Cocoa Pods By Milan Panchal
  • 23. Other 23 Using the files from a local path or repo (GIT/SVN)  From Local Machine: pod 'ExamplePod', :path => '~/Documents/ExamplePod'  From a git repository:  To use the master branch of the repository: pod 'ExamplePod', :git => 'https://github.com/eguser/ExamplePod.git'  To use a different branch of the repository: pod 'ExamplePod', :git => 'https://github.com/eguser/ExamplePod.git', :branch => 'dev'  To use a tag of the repository: pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :tag => '0.7.0'  Or specify a commit: pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :commit => '082f8319af’ Cocoa Pods By Milan Panchal
  • 24. Other (Continue) 24  Trying Out Pods  CocoaPods has a feature that enables you to download and try out a library before you use it in your project. It downloads the demo project of a Pod and opens it in Xcode.  Use the pod try [LIB_NAME] command to try out a Pod. pod try iOS-Category Cocoa Pods By Milan Panchal
  • 25. Other (Continue) 25 Installing The Same Pod In Multiple Targets The Ugly But Works Solution # Podfile platform :ios, ‘8.0’ use_frameworks! # My other pods target 'MyTests' do pod 'Quick', '0.5.0' pod 'Nimble', '2.0.0-rc.1' end target 'MyUITests' do pod 'Quick', '0.5.0' pod 'Nimble', '2.0.0-rc.1' end Cocoa Pods By Milan Panchal
  • 26. Other (Continue) 26 Installing The Same Pod In Multiple Targets The Elegant Solution platform :ios, ‘8.0’ use_frameworks! # My other pods def testing_pods pod 'Quick', '0.5.0’ pod 'Nimble', '2.0.0-rc.1’ end target 'MyTests' do testing_pods end target 'MyUITests' do testing_pods end Cocoa Pods By Milan Panchal
  • 27. Other (Continue) 27  Semantic Versioning: • A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative integers, and MUST NOT contain leading zeroes. X is the major version, Y is the minor version, and Z is the patch version. Each element MUST increase numerically. For instance: 1.9.0 -> 1.10.0 -> 1.11.0 Cocoa Pods By Milan Panchal
  • 28. 28 Thank You Cocoa Pods By Milan Panchal