14
Create Your Cocoa pods Submitted by: Pawan Ramteke Guided by: Amol Hirkane

Create Your First Cocoa pods

Embed Size (px)

Citation preview

Page 1: Create Your First Cocoa pods

Create Your Cocoa pods

Submitted by: Pawan Ramteke

Guided by:Amol Hirkane

Page 2: Create Your First Cocoa pods

What is CocoaPods?CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects.While it's very common to use CocoaPods in your iOS or OS X software projects, it's less common to actually create a pod others to use.

RequirementsTo create your cocoapod ,you have an account in https://github.com

To create a pod , you need to install cocoapods in your system.

Page 3: Create Your First Cocoa pods

Install CocoapodsTo install cocoapods , execute the following commands from the command line:

sudo gem install cocoapods

Page 4: Create Your First Cocoa pods

Create CocoaPodsGo to Terminal, execute the following command

pod lib create <Pod Name>

For example , pod lib create MyTextField

o After executing following command it will ask you number of questions:

o What is your email? - Enter your email id that you are using in github account.

o What language do you want to use?? [ ObjC / Swift ]o Would you like to include a demo application with your library? [ Yes / No ]

- Enter Yeso Which testing frameworks will you use? [ Spectra / Kiwi / None ] - Enter

Noneo Would you like to do view based testing? [ Yes / No ] - Enter Noo What is your class prefix? - Any Prefix that would be attach with your class

Name in the Example

Page 5: Create Your First Cocoa pods

After Answering all these questions and executing commands , your pod in set up. 

Page 6: Create Your First Cocoa pods

Xcode will open your brand new project ready for you to work on your pod.

Write short description

Write Detail description between DESC

Enter your github username

Page 7: Create Your First Cocoa pods

Push Project to githubTo push your project to github , register or login to github , then create new repository (Repository name should be your pod name ex . MyTextField).

Go to Pod path and then, from the command line, execute the following commands:

git add .(dot)

git commit –m “Initial Commit”git remote add origin https://github.com/<github_username>/<repositoryName>git push –u master origin

At this point, if you’ve done everything correctly and lint the .podspec file again, it should pass validation.

pod lib lint <PodName>.podspec  

Page 8: Create Your First Cocoa pods

Add code in pod fileOpen your project and find the file ReplaceMe.h under Pods/Development Pods/MyTextField/Pod/Classes/ and delete it.

Delete this fileDrag and drop your custom classes

Page 9: Create Your First Cocoa pods

Making Your Pod Available

Now that you have a fully functional pod running on your local machine, it’s time to make your pod available to others for inclusion in their projects. At a high level, this is accomplished by getting your new pod into the public Specs repository.

The Specs repository is the public place on GitHub where all public pods are indexed. Your pod's spec will be stored in the Specs repository on GitHub though.

There are three steps involved for submitting your pod.TaggingValidationPushing to Specs repository

Page 10: Create Your First Cocoa pods

TaggingTag your most recent commit and push it to the remote.

git tag 0.1.0

git push origin 0.1.0

output: Total 0 (delta 0), reused 0 (delta 0)

To https://github.com/PawanRamteke/MyTextField.git

 * [new tag]         0.1.0 -> 0.1.0

Page 11: Create Your First Cocoa pods

ValidationNext, run the following command from the command line to verify that everything is configured correctly between where your source code is stored and your .podspec file:

pod spec lint <podName>.podspec

Output :

> pod spec lint MyTextField.podspec

-> MyTextField(0.1.0)

Analyzed 1 podspec.

MyTextField.podspec passed validation.

Page 12: Create Your First Cocoa pods

Pushing to Specs Repository

Finally, push the spec to the Specs repository by executing the following command:

pod trunk push podName.podspec

ex: pod trunk push MyTextField. Podspec

output:>pod trunk push MyTextField. PodspecUpdating spec repo `master`

Validating podspec

-> MyTextField (0.1.0)

Updating spec repo `master`

- Data URL: https://raw.githubusercontent.com/Cocoa Pods/Specs/f7fb546c4b0f80cab93513fc228b274be6459ad2/Specs/BlinkingLabel/0.1.0/MyTextField. Podspec.json

- Log messages:

- June 29th, 20:40: Push for `MyTextField0.1.0' initiated.

- June 29th, 20:40: Push for `MyTextField0.1.0' has been push

Page 13: Create Your First Cocoa pods

Reference

https://github.com/PawanRamteke/MyTextField

My Cocoa pods

https://code.tutsplus.com/tutorials/creating-your-first-cocoapod--cms-24332

Page 14: Create Your First Cocoa pods

Thank you!!!

Enjoy Coding