0
I’m starting now with Swift (Xcode 7), I did the installation of cocoapods, but wanted to know how to import the functions that exist in the pod to a new project.
0
I’m starting now with Swift (Xcode 7), I did the installation of cocoapods, but wanted to know how to import the functions that exist in the pod to a new project.
0
pod init
and gives enter. This will create a file called Podfile
. Open this file in any editor.The file structure looks something like this:
platform :ios, '9.0'
use_frameworks!
target 'MyApp' do
end
Barter 'MyApp'
by the name of your app project
Between the do
and the end
, puts 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 touch the project from this Workspace. If you open the project yourself (as is usually done), the libraries won’t be there and Xcode won’t be able to build your project. A Workspace is just a project that brings together several projects in one, to make our life easier.Browser other questions tagged ios swift xcode
You are not signed in. Login or sign up in order to post.
Hello Lucas, first of all I appreciate the help, but I think I was not clear, because this part I’ve done...What I need to know is what I call a function that is inside the imported pod. I want to use the functions of the code: https://github.com/richa008/CurrencyTextField
– Luan Felix Coelho
within the pod I have the class "class Currencytextfield", so within this class I checked that there is a function: func getCleanNumberString(), I wanted to use this function to sum the values of textfield.
– Luan Felix Coelho
So Luan, I took a look at the class and this function is private, IE, only code written in that same file can access it. You have two options: 1. Edit the library code, make the function public or create a new function; 2. Write your own function, which takes the text from
CurrencyTextField
and does exactly what functiongetCleanNumberString()
ago.– Lucas Barbosa
I understood Lucas, I will do as I said and I say what happened, if she was public as I would call inside my Viewcontroller?
– Luan Felix Coelho
After initializing (
let c = CurrencyTextField()
), you can access asc.getCleanNumberString()
.– Lucas Barbosa