preface

The third framework is often used during development, and we can easily add third-party frameworks to our own projects with a pod install command. What if we also want to open source our own components or libraries so that others can install their own frameworks via the pod Install command? Next, publish your Pods into CocoaPods step by step. Check out this article for cocoaPods installation.

Create a project on gitHub

Start by creating a new project on gitHub. As shown below:

Clone the project, you can use the terminal to clone

git clone https://github.com/CaoXueLiang/CXLCategory
Copy the code

Or use sourceTree to clone the project locally.

Create a Podspec description file

CD To the root directory and run the command to create a podSpec file.

pod spec create CXLCategory
Copy the code

Once created, open the newly created CXLCategory. Podspec file in an editor and edit it. The final edit looks like the following:

  • s.nameIs the name of our library.
  • s.versionIs the original library code version number.
  • s.summaryIs a brief introduction to our library.
  • s.homepageDeclare the home page of the library.
  • s.licenseIs the authorized version used.
  • s.authorIt’s the author of the library.
  • s.platformIs the software platform supported by our library, which is useful when we finally commit for compilation.
  • s.sourceDeclares the address of the source code.
  • s.source_filesDeclares the location of the source code for our library, so this cannot be filled in incorrectly.

Verify that the created PodSpec file is available

After editing the PodSpec file, you need to verify that it works.

pod spec lint CXLCategory.podspec
Copy the code

When you see CXLCategory. Podspec passed Validation. “, the verification is successful.

4. Register Trunk and verify

1. Register the trunk and run the following command to register the trunk. Pod Trunk Register + mailbox + ‘nickname’

pod trunk register [email protected] 'caoXueLiang'
Copy the code

After registering, you will receive a confirmation email. Click the link to confirm. As follows:

Verify registration success with POD Trunk ME:

Publish to pod Trunk

Publish the Podspec file to pod using the pod trunk push + podspec file name

pod trunk push CXLCategory.podspec 
Copy the code

The message CXLCategory (0.0.1) sucessfully published is displayed

Use the published POD library in your project

pod 'CXLCategory'
Copy the code

Summary of Main Commands

1. Create a PodSpec file

pod spec create CXLCategory
Copy the code

2. Verify that the created PodSpec file is available

pod spec lint CXLCategory.podspec
Copy the code

3. The registered trunk

Pod Trunk Register + Mailbox +'nickname'
Copy the code

4. Verify that the trunk is successfully registered

pod trunk me
Copy the code

5. Publish to POD

Pod Trunk push + PodSpec file nameCopy the code

The Demo address:Github.com/CaoXueLiang…