-
-
Save eliakorkmaz/765093efc706eab90ffe1e543d42121e to your computer and use it in GitHub Desktop.
How to Create a Cocoa Pod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Notes for Creating a Cocoa Pod | |
Pod Version: 0.39.0 | |
OS: OS X El Capitain (10.11.3) | |
- - - - - - - - - - - - - - - - - - - - - - - | |
1. Install CocoaPods (https://guides.cocoapods.org/using/getting-started.html) | |
2. Create Xcode project to author the Pod | |
In Terminal, cd to a directory of choice and execute the following: | |
$ pod lib create YourPodName | |
What is your name? (This is added to the .podspec) | |
Bilbo Baggins | |
What is your email? (this will be added to the .podspec) | |
[email protected] | |
What language do you want to use? | |
Swift | |
Would you like to include a demo application with your library? (Will create an example project for your Pod) | |
Yes | |
Which testing frameworks will you use? (Note: Choosing None will use XCTest) | |
None | |
Would you like to do view based testing? (Note: Choosing Yes did not add XCTest's UITesting) | |
No | |
3. Create/Update Pod Spec | |
When Xcode opens, expand the 'Podspec Metadata' folder and open the .podspec file (YourPodName.podspec) and change the following: | |
s.name | |
Confirm this is the correct name to be used when publishing your Pod | |
s.version | |
Change to appropriate version e.g. "1.0.0" | |
s.summary | |
Change to a one sentence description | |
s.description | |
Move mouse cursor at the end of <<-DESC, press enter, and add description between <<-DESC and DESC. | |
Use pod lib lint Your.podspec to make sure this is formatted correctly. | |
s.homepage | |
It is stubbed with: "https://github.com/<GITHUB_USERNAME>/PodName" | |
Explicitly set the homepage to be the GitHub repo URL e.g. "https://github.com/ccabanero/PodName" | |
Note, you will create this repo in GitHub later (see step 4 below). | |
s.source | |
It is stubbed with: { :git => "https://github.com/<GITHUB_USERNAME>/PodName.git", :tag => s.version.to_s } | |
Explicitly set the username. e.g. { :git => "https://github.com/ccabanero/PodName.git", :tag => s.version.to_s } | |
Note, you will create this repo in GitHub later (see step 4 below). | |
s.social_media_url | |
It is commented out, so I removed the comment. | |
It is stubbed with a placeholder user name. | |
Explicitly set user name. e.g. 'https://twitter.com/clintcabanero' | |
s.platform | |
It is stubbeed with 8.0 | |
In Xcode, I made sure my deployment target was 8.0 (i.e. the lowest supported OS) | |
s.framework | |
It is commented out, so I removed the comment. | |
It is stubbed with # s.frameworks = 'UIKit', 'MapKit' | |
Explicitly change as needed e.g. s.frameworks = 'UIKit', 'QuartzCore' | |
s.dependency | |
It is commented out. Because I have no dependencies on other pods, I left this commented out. | |
During all pod spec updates, use the following to Lint the .podspec to ensure you didn't mess it up ;): | |
$ pod lib lint YourPodName.podspec | |
4. Create the Pod's Remote Git Repo (on GitHub) and Push | |
Go to GitHub and create a repo. | |
Note, that the URL should match what you declared for s.source and s.homepage above. | |
Note, no need to add a MIT License file, its already in the Xcode workspace. | |
Note, no need to add a README file, there is a starter README in the Xcode workspace. | |
Note, no need to add a .gitignore, there is a starter in the Xcode workspace. | |
Then push the project to GitHub with the following: | |
$ git add . | |
$ git commit -m 'Initial commit' | |
$ git remote add origin https://github.com/ccabanero/yourpodname.git | |
$ git push -u origin master | |
xxxxx$ git push --set-upstream origin master | |
5. Add Code for your Custom Pod | |
In Xcode, expand Pods -> Development Pods -> YourPodNameFolder -> Pod -> Classes -> ReplaceMe.swift. | |
Delete the ReplaceMe.swift and add your custom library code (or start developing it). | |
NOTE! Your Swift library needs to have it's class(es) declared as 'public' for you to see them in the example project!!! | |
Install the pod in the example project. | |
$ cd Example | |
$ pod install | |
In Xcode, use the pod and Run in a simulator to test. Continue devloping and testing your pod. | |
6. Pod README | |
In Xcode, expand your pod target -> Podspec Metadata -> README.md | |
Note, when you executed 'pod lib created ...' it started the README.md | |
Create a animated gif of your library if it is a UIControl. | |
a. Record simulator using Quick Time Player. | |
b. Use Photoshop (or other tools) to export as animated .gif | |
7. Publishing the Pod | |
Tag your pod (should be the same as what is declared in your .podspec) | |
$ git tag 1.0.0 | |
$ git push origin --tags | |
Validate your pod | |
$ pod spec lint MyPod.podspec | |
Push to the Public Specs Repository | |
Register a session to push | |
$ pod trunk register [email protected] 'Bilbo Baggins' --description='mac book pro' | |
Open your email client - and click the link in it. You will then be informed you're ready to push. | |
Push it | |
$ pod trunk push MyPod.podspec | |
Source: These notes are based on the great web article located at this URL: http://code.tutsplus.com/tutorials/creating-your-first-cocoapod--cms-24332 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment