Componentization improves our development efficiency and allows us to understand knowledge more deeply. Many of the frameworks we see on Github are particularly valuable for deep learning, and we can also submit our own widgets and frameworks to Cocoapods for more people to learn from. Today we’ll cover the basic steps and precautions for submitting to Cocoapods.

Step 1: Create a remote repository on Github (or some other repository) and write out the ReadMe.

Step 2: Package the components that you have written (generally put them in a folder). The structure is like this: For example, put the HZAlertView component outside the project and in the project, and keep the contents in the two folders the same. The outside is for users to download, and the inside is for projects to use.





After the first two steps, we have the remote repository and background code, and then we need a local repository associated with the remote repository. So we can submit the code and version to Github.

Step 3: Create the local repository and associate the remote repository. If necessary, please go to the basic use of Git.

Create a local Git, associate it with a remote Git, and pull the contents of the remote repository to the local git.

Step 4: Create a spec file. Using the pod Spec Create HZAlertView command in your terminal (if you have already CD to the project path, of course) will generate a spec file in your project directory.




Code:

Pod::Spec.new do |s|

s.name = “HZAlertView”

S.v ersion = “0.0.1”

S. summary = “Componentized alertView”

s.description = <<-DESC

Hua Zhuo componentized alertView code collation

DESC

s.homepage = “https://github.com/jihuaibin2017/HZAlertView”

s.license = “MIT”

s.license = { :type => “MIT”, :file => “LICENSE” }

s.author = { “xxxx” => “[email protected]” }

s.platform = :ios

S.s ource = {: git = > “https://github.com/jihuaibin2017/HZAlertView.git”, : tag = > “0.0.1}”

s.source_files = “HZAlertView/**/*.{h,m}”

s.requires_arc = true

end

Step 5: Commit the local code and version to the remote repository. Check git’s version submission. Git add.,git commit -m” XXX “, git tag XXX,git push –tags, git push origin master

Podspec –allow-warnings Verify the validity of a spec file using the pod lib lint hzalertView. podSpec –allow-warnings command

Step 7: Use pod Trunk to push hzalertView. podspec –allow-warnings submit to cocoapods

Step 8: Update the local POD code base with the pod setup directive. So you can find your own components.

Finally, the code to update the component starts at step 5. Don’t forget to change the spec version to match the new tag version.

The above steps are very rough and will be refined gradually in the future.