Small knowledge, big challenge! This paper is participating in theEssentials for programmers”Creative activities

This paper also participates inProject DigginTo win the creative gift package and challenge the creative incentive money

See the essence through the problem!!

CocoaPod library production process

1. Install cocoapods

This step refers to the online installation tutorial, many, very detailed.

2. Registering trunk (required for cocoaPod Public Library publishing)

Register cocoapods’ trunk and run the following command from the terminal:

Pod Trunk register [email protected] 'Registered name' --verboseCopy the code

or

Pod Trunk register [email protected] The registered name --verboseCopy the code

Once you have registered, you will see the following confirmation email:

[!]  Please verify the session by clicking the link in the verification email that has been sent to [email protected]Copy the code

3. Create a remote POD repository

Create a POD repository on your own remote Git. This article uses CLTSpecs as an example to create a CLTSpecs repository in your company’s private Git repository. Detailed operations are omitted. (Public library is not required)

4. Add the associated local POD repository

Cocoapods /repos:

pod repo add CLTSpecs http://repo.we.com/clt.zhang/cltspecs.git
Copy the code

CLTSpecs repositories on Github are cloned locally, and a CLTSpecs repository is generated under Repos, similar to cocoapods’ Master repository.

5. Create a remote project repository

Create a project repository on your own remote Git. This article uses CLTFoundation as an example to create a CLTFoundation project repository in your company’s private Git repository. Detailed operations are omitted.

6. Create a local POD project and associate the remote project repository

CD Go to the directory where you want to store the local project and execute the following statement:

pod lib create CLTFoundation
Copy the code

Make the following choices as prompted:

What platform do you want to use?? [ iOS / macOS ]
 > iOS
What language do you want to use?? [ Swift / ObjC ]
 > ObjC
Would you like to include a demo application with your library? [ Yes / No ]
 > Yes
Which testing frameworks will you use? [ Specta / Kiwi / None ]
 > NOne
Would you like to do view based testing? [ Yes / No ]
 > NO
What is your class prefix?
 > CLT
Copy the code

This will create a Pods project from cocoapods’ Pods template in the directory you specify, including the Pods and Example demo project.

7. Edit the POD project and modify the. Podspec file

Edit the POD project, delete replaceme. md under the classes file in the POD directory, and add your own classes to encapsulate. This question uses cltrootobject. h and cltrootobject. m as examples. Edit the. Podspec file as follows:

Pod: : Spec. New do | s | s.n ame = 'CLTFoundation' # Pod library name s.v ersion = '0.1.0 from' # Pod library version number s.s ummary = 'CLTFoundation.' # simple introduction, No more than 140 words s.description = << -desc # Detail description This is my Foundation library. Sheldon horowitz at DESC # warehouse project homepage omepage = 'http://repo.we.com/clt.zhang/cltfoundation' # agreement, MIT s.license = {:type => 'MIT', :file => 'LICENSE'} # author s.thor = {'clt.zhang' => '[email protected]'} Can indicate the label, branches and other s.s ource = {: git = > 'http://repo.we.com/clt.zhang/cltfoundation.git' : tag = > s.v ersion. To_s} # in the import, The referenced name s.module_name = 'CLTFoundation' # system version s.iis. Deployment_target = '8.0' # Classes and files that the POD library needs to include s.souce_files = 'CLTFoundation/Classes/*.{h,m}' #s.dependency 'AFNetworking' endCopy the code

CD go to the Example directory and run pod Install to get the following project structure:

-CLTFoundation
-Pod
 |_Podfile
 |_Development Pods
 |  |_CLTFoundation
 |  | |_ReplaceMe.md
 |  |_Pod
 |  |_Support Files
 |_Frameworks
 |....
Copy the code

8. Check the. Podspec file

Execute the following statement to check the podSpec file:

pod lib lint
Copy the code

If an insignificant warning fails the check, type the following command: –allow-warnings

9. Push to submit the local POD project to remote

To submit the local POD project to remote, execute the following statement under CLTFoundation:

Git add. Git commit -m "Add CLTFoundation class files" git push origin masterCopy the code

Push the local project to the remote POD project repository

10. Tag the POD project and push it to remote

Execute the following statement to label the project with the same label as the POD version:

Git tag 0.1.0 Git pushCopy the code

After successful push, the following information will be displayed:

Total zero (0) delta, reused zero (0) delta To http://repo.we.com/clt.zhang/cltfoundation.git * [new tag] - > 1.0.1 1.0.1Copy the code

11. Check remote podSpec

Execute the following statement to check the remote podSpec:

pod spec lint 
Copy the code

If you have a warning and add –allow-warnings, you are almost done if you pass the verification.

12. Upload the. Podspec of your local POD project to your local and remote repositories

In our own Spec warehouse, not Cocoapods’, I have a CLTSpecs warehouse

Public library:

pod trunk push CLTFoundation.podspec
Copy the code

Private libraries:

pod repo push CLTSpecs CLTFoundation.podspec
Copy the code

With a warning and –allow-warnings, Cocoapods uploads the PodSpec file to the CLTSpecs repository.

13. Finished, using your own POD library

Now we can search our pod library through Pod Search CLTFoundation and specify our own repository status in our podfile

[email protected]: cli. Zhang/cltspecs. Source 'git' private warehouse path pod 'CLTFoundation'Copy the code

If not, perform the following POD repo update;