Publishing with pod Trunk is a four-step process
1.Registered trunk2.Submit the locally prepared framework and.Podspec files to the Github repository and tag them.3.Verify that the PodSpec file passes4.Push the PodSpec file to the Cocoapod TrunkCopy the code
1. Registered trunk
1.1 What is a Trunk?
Trunk official address
CocoaPods Trunk is an authentication and CocoaPods API service. To publish new or updated libraries to CocoaPods for public distribution, you need to register with Trunk and have a valid Trunk session on the current device.
The architecture diagram is as follows:
1.2 trunk registration
-
Open terminal and run the following command: pod Trunk register mailbox ‘user name’ –description=’ computer description ‘
-
After execution, the following information will appear. You have sent an email to the registered mailbox, and you need to click the link to confirm. One caveat: If you can’t find your inbox, look in the trash.
- After clicking the link, cocoapod web page will be redirected to indicate successful registration. At this time, you can view personal information and execute commands on the terminal
pod trunk me
Personal information includes Name, email address, and all pods uploaded by myself
Once you can see your personal information, you can start step 2
2. Submit the locally prepared framework and. Podspec files to the Github repository and tag them.
2.1 Create a new repository on Github as follows:
2.2 Cloning a Warehouse to the Local PC
2.3 Put the local frames into the repository folder
Notice there are two cases here
1. Put only frame files as shown: This method requires you to create your own. Podspec files
This way, the project template will automatically generate a. Podspec file
- The test sample project can be generated using pod to create component templates
Terminal: pod lib create YCCodeKit
- Put your framework code in the Classes file
- perform
pod install
The sample project will import the local framework into the project, which can be tested locally, as shown in the figure below:
This method is recommended for testing functions and later version upgrades
2.4 Generate a. Podspec file for the framework and write its contents
- The warehouse address and the code address of the warehouse correspond to the following picture information:
- The location of the.podpsec file is shown below:
2.5 Submit the local code to the repository and tag it
- Submit the code to the repository and tag it as shown in the picture: I use the Sourcetree tool on my side and also use the command.
- Check to see if the repository has tags
3. Verify that the PodSpec file is valid
3.1 Authentication commands are classified into local and remote commands as follows:
-
Pod Lib Lint YCCodeKit. Podspec
-
Lint YCCodeKit. Podspec (Verify that your pod is valid locally and remotely)
XXX passed Validation proves that the push operation has passed
If an error or warning is reported, you can append information to the command
--allow-warnings allow warnings --verbose output details --skip-import-validation skip some validation --use-libraries use static librariesCopy the code
3.2 Common verification errors are as follows:
-
xcodebuild: Returned an unsuccessful exit code. You can use –verbose for more information.
- You can skip it using this command
pod spec lint YCCodeKit.podspec --skip-import-validation
- You can skip it using this command
-
The code has been determined that there is no problem, using the old version number to tag, pod Spec Lint /trunk push failed
- Attempt to clear the POD cache
pod cache clean -all
Verify again after clearing
- Attempt to clear the POD cache
4. Push the PodSpec file to the Cocoapod Trunk
-
Implement push to trunk: pod trunk push yccodeKit. podspec –verbose –allow-warnings
-
After the push is successful, local verification can be performed to verify whether the push is generated and execute pod Trunk me to view personal information
-
After success, you can run Pod Search YCCodeKit to view the search results
-
Problem record: Sometimes it is determined that push is enabled but cannot be found locally. This can be done by using the following methods:
- 4.1. First check whether your local index library contains master, you must have this index library. If not, you need to download a copy from Git
-
4.2. Make sure there are the index of the master Library, delete ~ / Library/Caches/search_index CocoaPods directory. The json file input terminal: rm ~/Library/Caches/CocoaPods/search_index.json
-
4.3 Update pod repo update pod search XXX again
5. Finally, list some pod trunk operations
Pod Trunk me: view personal trunk information POD Trunk info XXX: View specified POD information POD Trunk delete XXX versionName: Remove pod Trunk from the official pod library: Drop all versions of the podCopy the code