I'm now starting with Swift (Xcode 7), I installed cocoapods, but wanted to know how to import the functions that exist in the pod to a new project.
I'm now starting with Swift (Xcode 7), I installed cocoapods, but wanted to know how to import the functions that exist in the pod to a new project.
pod init
and give enter. This will create a file named Podfile
. Open this file in any editor. The file structure looks something like this:
platform :ios, '9.0'
use_frameworks!
target 'MyApp' do
end
Swap 'MyApp'
by the name of your app project
Between do
and end
, put the libraries you want to use this way (I'll put 3 libraries as an example):
target 'MyApp' do
pod 'Alamofire'
pod 'PKRevealController'
pod 'SwiftyJSON'
end
pod install
<NomeDoSeuProjeto>.xcworkspace
. Open this file. From now on, just move the project from that workspace. If you open the project by yourself (as you normally do), the libraries will not be there and XCode will not be able to build your project. A workspace is just a project that brings together several projects in one, to make our life easier.