IOS development – create podspec files and add pod support for your own projects

IOS development - create podspec files and add pod support for your own projects
Zhangbei grassland

The opening.

As a iOS developer, CocoaPods must be used, not used? Click here to the wall.

Cocoapods is a package manager for iOS development, has brought great convenience to our development, and more and more third party libraries support Pod, can Pod fool integrated into their own projects, then the problem, I also have a series of small tools, how to make it support pod integration then let other friends convenient use?

Just recently, the project wasn’t tight enough. I tried it myself. Here’s a record of the process, a memo, and two……

In fact, the online articles are not necessarily beyond count, but for their own, for example, then write the things I think are suitable for me, but not necessarily suitable for you are reading this, or is there a content below can help you, if so, I am also very happy

There are a lot of imperfections in this article, and the time will be enough to improve it

A poorly written brick mercy

Get some action

I’m here to take a small demo as an example, the purpose is to extract some of the category in the project to support pod

1. upload project source code

Upload the project source code to the gitHub warehouse, and then clone to the local (take iOS_Category as an example – the source code here), if the project is in the warehouse of gitHub, directly clone to the local

2. create the podspec file for the project

  • Use the terminal command CD to the local project directory and execute the following command:
$pod spec create iOS_Category

At this point, a iOS_Category.podspec file is generated locally

  • Open the.Podspec file with the editor (I use Sublime Text myself)

Remove unnecessary notes (here only briefly introduced the basic usage, so only one part must go to field more field)

Pod:: do |s| = "iOS_Category" s.version = "0.0.1" = "s.summary all kinds of categories for iOS develop s.description = < < -DESC this project provide all kinds of categories for iOS developer DESC s.homepage =" "s.license =" MIT "s.license = {type: =>" MIT ": file, => LICENSE} {=> =" yongqianvip ";" yongqianvip@***.com "} = s.source = {IOS: s.platform: git =>, tag: =>" 0.0.1 "}; s.source_files =" Classes "," iOS_Category/Classes/**/*.{h, m} "s.exclude_files = Classes/Exclude"" S.public_header_files = "iOS_Category/Classes/UIKit/UI_Categories.h", "iOS_Category/Classes/Foundation/Foundation_Category.h", "iOS_Category/Classes/**/*.h", "s.requires_arc" = "true", "end"
  • Verify the podspec file

After editing the podspec file, you need to verify that the file is available. The podspec file does not allow any Warning or Error
to execute the command

$pod lib lint

In case of

-> iOS_Category (0.0.1) iOS_Category passed validation.

Verify that validation is passed, otherwise, modify the podspec file according to the prompt and verify again until validation passes

Incidentally, Xcode allows warnings to exist, so you can screen warnings by command

$pod lib lint --allow-warnings

If Error appears, but the tooltip is insufficient, you can add –verbose to get more error information

$pod lib lint --verbose

3. hits tag upload podspec

The tag in the podspec file needs to be specified. After the above operation is completed, tag is given to the project

$git, tag, -m, first, release, with, podspec, iOS_Category, 0.0.1, $git, push, --tags

Finally, use the pod trunk command to push the podspec file to the CocoaPod official library

Pod trunk need to register the practice here no longer go to CocoaPod.

After the pod trunk is set, execute the command

$pod trunk push iOS_Category.podspec

This process can be time-consuming, for reasons you understand

4. final

If everything goes well

Pod search iOS_Category

You can find the project just now, and there are installation commands &lt, pod,’iOS_Category’,’~&gt, 0.0.1′, >