DEV Community

Cover image for Create You Own Pod
NalineeR
NalineeR

Posted on

Create You Own Pod

So far you would have used pods as a dependency in your project.
Do you want to create your own pod and help others?

Let's do it by below easy steps -

  1. Open terminal and type the command -> pod lib create Your_Pod_Name
    Image description

  2. It will ask you some questions and then will create an XCode project for you. This Xcode project will contain some files added for you

    1. .podspec -> will contain the details/specifications about your library
    2. README.md -> the README file in markdown format.
    3. License -> this will hold the default MIT license. You can replace with your own if required.
    4. ReplaceMe.swift -> A default swift file to guide where to add your files.

Lets setup the project now -

  1. README.md - Open this file and add/edit the details relevant to you. You can remove the details which are not required.
  2. Addling classes -
    1. Delete the Replace Me file.
    2. Click on MyFirstPod under Pods and Create a folder with name Sources
    3. Now add your library files to this folder. Image description
  3. Adding Resources - You need to add the resources like xib,asset,icons etc to a separate folder. If you don’t have any then you can skip this step.
    1. Create a folder named Resources on the same level as we did for Sources.
    2. Now add your resource files to it here
  4. Update folder path in podspec file - Open you podspec file and set the following keys one by one
    1. set s.source_files to this s.source_files = 'Sources/**/*.swift'
    2. s.resources to below. You can add the extension of files you have added to your project. s.resources = "Resources/**/*.{png,xib}"
    3. Add the description and summary for your project Image description
  5. Deploy your library -
    1. Push to your Git Repo -
      1. Create a repository for this project and push your project to it.
      2. Now we need to add a tag to the last commit. This tag should be the one mentioned in podspec file on s.version. This tag is becomes the version of your pod.
    2. Validate -
      1. Open terminal
      2. Traverse to the folder where the podspec file exists.
      3. Run pod lib lint --allow-warnings. This will validate your library.

Image description
3. Deploy to public - Run pod trunk push --allow-warnings. If everything goes right then you will see as below -
Image description

That's it. Now you can install this pod in any other project.πŸŽ‰

You can find the demo project on below link -
https://github.com/NalineeR/NRCustomPod

Oldest comments (0)