In general, we are writing programs, are using Cocoapods to manage the framework, but how to write their own tool class release into the framework, after searching for resources, finally achieve the following functions, the steps are as follows: 1. registered

bogon:~ Allison$ pod trunk register [email protected]  "Allisonwangjj"
Copy the code

After executing the registration command, open the corresponding mailbox and you can see that we have received an email, as shown in the picture below

2. Query POD registration information

bogon:~ Allison$ pod trunk me - Name: Allisonwangjj - Email: [email protected] - Since: April 26th, 01:10 - Pods: None-sessions: - April 26th, 01:10-September 1st, 01:21. IP: 113.204.101.114 Bogon :~ Allison$Copy the code

Since I am publishing the framework for the first time, there is no information here. At this point we go to GithHub. To create a framework. As is shown in

Now let’s go through terminal and see if anyone else has used this name “FFAdditions”

bogon:~ Allison$ pod search FFAdditions
Copy the code

A [!] Unable to find a pod with name, author, summary, “Or description matching FFAdditions” error prompt means that there is no way to find the name, which means that the frame name has not been used yet, so let’s register one as soon as possible. Click “Register” and the interface below will appear, indicating that the registration is successful. Copy the URL address.

We create a new repository with SourceTree, as shown in Figure 5

At this point, we open Up Xcode, create a new project in git, drag in one of our usual utility classes, and push the utility class onto Git.

3. Generate the spec file (this is very important; make sure you have the URL in your home directory on GitHub)

cd /Users/wuxianlvzhou/FFAdditions/AdditionsFrame 
bogon:AdditionsFrame Allison$ pod spec create https://github.com/AllisonWangJiaoJiao/FFAdditions
Copy the code

When Specification created at ffextractor.podspec appears on the terminal, it indicates that the framework has been created successfully (or if you find the corresponding file directory and find an additional ffextractor.podspec file, it also indicates that the framework has been created successfully, as shown in Figure 8).

4. Edit the spec file and open it with Xcode. You’ll find a lot of content.

Pod::Spec.new do |s|

  s.name         = "FFAdditions"
  s.version      = "0.0.1"
  s.summary      = ""
  s.homepage     = "https://github.com/AllisonWangJiaoJiao/FFAdditions"
  s.license      = "MIT"
  s.author       = { "AllisonWangJiaoJiao"= >"[email protected]" }
  s.platform     = :ios, "8.0"
  s.source      = { :git => "https://github.com/AllisonWangJiaoJiao/FFAdditions.git", :tag => s.version }
  s.source_files  = "FFAdditions"."AdditionsFrame/AdditionsFrame/FrameTools/*.{h,m}"
  s.requires_arc = true
end
Copy the code

######. Podspec file parameters:

Pod::Spec.new do |s|
  s.name         = "Name of your project"
  s.version      = "Version of the project"
  s.summary      = "Project Description"
  s.homepage     = "The home page of the project, usually the Github address will do."
  s.license      = "License: generally MIT"
  s.author       = { "Author name"= >"Your email"} // The lowest supported version, such as ios 8.0 s.platform = :ios,"8.0"// The source code is your github address."Your Github address", :tag => "Project tag"} // The source file path s.source_files ="WCL"."WCL/**/*.{h,m}" , "WCL/*.{swift}"// ARC turns on s.equires_arc =true
Copy the code

Key: Create labels in Sourcetree. Push the tag to a remote server separately, so that when someone uses our framework, they will download all the current files corresponding to the tag at our GitHub address.

Note: there is a change in these two sentences that needs special attention
S.ource = {:git =>"https://github.com/AllisonWangJiaoJiao/FFAdditions.git", :tag => s.version }
  s.source_files  = "Classes"."Classes/**/*.{h,m}"S.ource = {:git =>"https://github.com/AllisonWangJiaoJiao/FFAdditions.git", :tag => s.version }
  s.source_files  = "FFAdditions"."AdditionsFrame/AdditionsFrame/FrameTools/*.{h,m}"
  s.requires_arc = true
Copy the code

Close the ffaddition. podspec file, go back to the terminal, and compile and verify each version.

bogon:AdditionsFrame Allison$ pod spec lint
Copy the code

After executing the command, the following error [!] occurs The spec did not pass validation, due to 2 errors. [!] The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a .swift-version file to set the version for your Pod. For Example to use Swift 2.3, run: echo “2.3” >. Swift-version

Check the error message and find that summary is not written, open it again with Xcode and add summary information as follows: S.sammary = “This is my framework” run pod Spec Lint again on the terminal to verify, wait a few minutes, and “ffaddition.podspec passed validation.” means verified.(excited 😂…..)

5. Push (push only after verification is passed)

bogon:AdditionsFrame Allison$ pod trunk push
Copy the code

This command takes several minutes to execute. During this process, no warnings ⚠️, validation fails (the current version must have no warnings), and warnings can be eliminated by modifying the precompile instructions. After executing the pod Trunk push command, the following command appears

bogon:AdditionsFrame Allison$ pod trunk push [!]  Found podspec `FFAdditions.podspec` Updating spec repo `master` warning: inexact rename detection was skipped due to too many files. warning: you may want tosetYour diff.renamelimit variable to at least 4785 and retry the command. CocoaPods 1.2.1 is available. `sudo gem install cocoapods` For more information, see https://blog.cocoapods.org and the CHANGELOGforThis version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.2.1 Validating podspec - > FFAdditions (0.0.1) Updating spec repo 'master' CocoaPods 1.2.1 is available. To update use: `sudo gem install cocoapods` For more information, see https://blog.cocoapods.org and the CHANGELOGforThis version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.2.1 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 🎉 Congrats 🚀 FFAdditions (0.0.1) Successfully published 📅, April 26 th, 02:31 🌎 https://cocoapods.org/pods/FFAdditions 👍 Tell your friends! --------------------------------------------------------------------------------Copy the code

To upgrade, use sudo gem install cocoapods. To create a new Xcode project, UseAdditionsFrame, execute the following command steps

bogon:AdditionsFrame Allison$ cd /Users/wuxianlvzhou/FFAdditions/UseAdditionsFrame 
bogon:UseAdditionsFrame Allison$ pod install
Copy the code

If you see a Podfile in your directory, double-click on it to open the file, add pod ‘FFAdditions’ and run on the terminal

bogon:UseAdditionsFrame Allison$ pod install
Copy the code

You can now see a project for.xcWorkspace.

Open the project as shown below.

So far the whole process is finished, here to make a record, convenient for their future study. Phenomenon of common mistake is to see my another blog post [CocoaPods release added framework (upgrade)] www.jianshu.com/p/347f125bb…