Allow your open-source projects to support CocoaPods and open-source projects to support cocoapods
During the test, you can find a self-encapsulated method or UI control. Here we use the Redirect redirection Request body encapsulated by me as an example.
1. Create a Redirect on github. Important: select the open-source protocol (MIT) (if GitHub is available, Baidu first)
2. Use Github Desktop Clone (Clone) Redirect to computer Desktop
Note: Remember to update the items in the Redirect File in time. Please refer to Baidu for instructions on how to use Github Desktop.
3. cd to the current directory
$ cd Redirect
4. Create a podspec file and run the following command:
$ pod spec create Redirect
5. Edit the podspec file. Run the command vim to open the file. (You can also use the text editor to open the file)
$ vim Redirect.podspec
6. A template is automatically generated after the template is created, which contains detailed annotations. You only need to modify the file as needed,
The following is edited during the test (for more configuration, refer to the podspec file of other open-source projects ):
(Note: You can delete drops starting)
Pod::Spec.new do |s| s.name = "Redirect" s.version = "0.0.1" s.summary = "Redirecting Requests." s.description = <<-DESC This is a Redirecting Requests. DESC s.homepage = "http://www.cnblogs.com/ljcgood66/" s.license = "MIT" s.author = { "LiJunCheng" => "1139981137@qq.com" } s.platform = :ios s.source = { :git => "https://github.com/ganlinmeng/Redirect.git", :tag =>"0.0.1" } s.source_files = "Redirect", "Redirect/**/*.{h,m}" s.exclude_files = "Classes/Exclude" s.framework = "UIKit" # s.frameworks = "SomeFramework", "AnotherFramework" # s.library = "iconv" # s.libraries = "iconv", "xml2" # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # If your library depends on compiler flags you can set them in the xcconfig hash # where they will only apply to your library. If you depend on other Podspecs # you can include multiple dependencies to ensure it works. # s.requires_arc = true # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } # s.dependency "JSONKit", "~> 1.4"end
S. name: name, a keyword for pod search,Note:
The name must be the same as that of. podspec. Otherwise, an error is returned.
S. version: version Number
S. ios. deployment_target: Minimum supported pod version
S. summary: overview
S. homepage: Home Address of the project
S. license: license
S. author: author
S. social_media_url: Social Network URL
S. source: Project address
S. source_files: source file to be included
S. resources: resource file
S. requires_arc: whether ARC is supported
S. dependency: Dependent database, cannot depend on unpublished Database
S. dependency: Dependent library. If there are multiple dependency libraries, you can write them like this.
(Note: You can also write it like this:s.license= { :type => "MIT", :file => "LICENSE" }
7. Create a tag and push it to github. Execute the following commands in sequence:
$ git add .$ git commit -m "0.0.1"$ git tag 0.0.1$ git push --tags$ git push origin master
(Note: After git push-tags is executed, the supervisor will ask you to enter the GitHub account and password)
Username for 'https://github.com':Password for 'https://ganlinmeng@github.com':
8. Verify the podspec File
$ pod spec lint Redirect.podspec
If the terminal prompts (but you can use '-- allow-warnings' to ignore them ).
You can
$ pod spec lint Redirect.podspec --allow-warnings
- If the verification fails, a detailed ERROR and WARING prompt will be displayed. Solve the problem as prompted and return7Step by step.
Note:Before restarting the database, we need to delete the tag of the remote database and the local tag. The command is as follows:
$ Git tag-d 1.2 // Delete local tag $ git push origin: refs/tags/1.2 // Delete remote library tag
If the verification is passed
9. If the request is submitted for the first time, run the following command:
$ Pod trunk register Write email here 'here name '-- description = 'here description'
After the execution is complete, an email will be sent to your mailbox and you will click the link in the mailbox!
Then submit it to CocoaPods
(Note: Since I used -- allow-warnings when verifying the podspec file, -- allow-warnings is also added here)
pod trunk push Redirect.podspec --allow-warnings
10. After submission, you can use cocopods to find Redirect.
(Note: after the project is submitted, the pod search Command will not be found because the local index is not updated. Run the following command to delete the index file:
rm ~/Library/Caches/CocoaPods/search_index.json
Finally, I found my project through the pod search Command.
If the problem persists, run the command again.
rm ~/Library/Caches/CocoaPods/search_index.json
pod setup
Then perform pod search,
-Perfection
In this way, you can use it.
Finally, thank you!
Refer:
Https://www.jianshu.com/p/0e1d796b2a42
Https://www.jianshu.com/p/a1339d45a324
Http://www.cocoachina.com/ios/20160301/15459.html
Https://www.cnblogs.com/richard-youth/p/4704413.html
Https://www.jianshu.com/p/283584683b0b
Https://www.cnblogs.com/xzjxylophone/p/4956469.html
Https://www.jianshu.com/p/b5e5cd053464