We love using CocoaPods to manage dependencies in all our iOS projects, it enables us to create a project and start working in literally few minutes!
However I started having some hard times keeping my iOS projects in sync with what the amazing Swift community is doing, not only the language is changing fast, but projects as well, new projects are born and old ones are being refactored and replaced quickly.
In this tutorial, I’ll explain a suggested workflow for managing 3rd party dependencies and how to make the Podfile
, well, a little bit more interesting 😉
Let’s assume that we’re working on version 1.0.0 of a project that has the codename Apollo
A codename is a something we use at my company to identify our project publicly while in development without disclosing much information about them.
Semantic Versioning is what we use for versioning.
Let's also assume that the following dependencies have to be used to build the project
For each project from the dependencies above:
{codename}-{version}
, for our example it will be apollo-1.0.0
Podfile
:platform :ios, '9.0'
# Global variables
REPO = 'https://github.com/GITHUB_ORGANIZATION_NAME'
BRANCH = 'CODENAME-VERSION'
target 'TARGET_NAME' do
use_frameworks!
## Dependencies
pod 'LIBRARY_1', git: "#{REPO}/LIBRARY_1", branch: "#{BRANCH}"
pod 'LIBRARY_2', git: "#{REPO}/LIBRARY_2", branch: "#{BRANCH}"
# ...
end
For our example:
platform :ios, '9.0'
REPO = 'https://github.com/GITHUB_ORGANIZATION_NAME'
BRANCH = 'apollo-1.0.0'
target 'Apollo' do
use_frameworks!
pod 'RxSwift', git: "#{REPO}/RxSwift", branch: "#{BRANCH}"
pod 'Moya', git: "#{REPO}/Moya", branch: "#{BRANCH}"
pod 'Kingfisher', git: "#{REPO}/Kingfisher", branch: "#{BRANCH}"
end
pod update
.We’re now working on a script to update our forks, create new branches, update the
Podfile
and automate the whole process.
If you have any questions or suggestions, don’t hesitate to reach out to me on Twitter.
Use the power of protocols and generic types to avoid extension conflicts
Use generics, protocols, and extensions to get rid of massive view controllers