preface

CocoaPods is a project for managing Xcode dependent libraries. Through CocoaPods, we can intuitively, centrally and automatically manage our third-party libraries for our projects.

This article describes how to publish the framework to Cocoapods and the common problems encountered in publishing.

Register CocoaPods’ Trunk service

  1. After executing the following command, go to the mailbox and click the Trunk authentication link.
$ pod trunk register yourEmail 'your name' --verbose
Copy the code

Example:

pod trunk register [email protected] ‘anyrtc’ –verbose

  1. Query registration information.
$ pod trunk me
Copy the code

Cocoapods release

Common CocoaPods releases use Git on Github, while spec.source supports git, HG, BZR, SVN, and HTTP. Git is recommended for daily development.

Git way

  spec.source = { :git => "https://github.com/anyrtc/xxx.git", 
                     :tag => "#{spec.version}",
                     :submodules => true }
Copy the code
  1. Create a project

  1. Clone the project from Github, use terminal to go to the root directory, and create it
pod spec create xxx
Copy the code

  1. Modifying a Configuration File

How do I modify the configuration file? As shown in theCocoapods guides

Spec configuration, toCocoaPods To query information about all libraries on Cocopoads

  1. Submit to Github repository in the following directory:

Git add. Git commit -m "commit message" git push -u origin masterCopy the code
  1. Generate a tag and push it, corresponding to spec.source.
$git tag '1.0.0' $git push --tags $git push origin master $pod spec lint --allow-warnings (detailed pod spec lint XXX. Podspec --verbose) POD Trunk push or POD Trunk push XXX. Podspec or POD trunk push XXXCopy the code

The HTTP method

  spec.source = { :http => 'https://anyrtc.com/ios/xxx.zip'}
Copy the code

Create and modify the spec configuration file by pod Trunk push

Cocoapods publishes FAQs

  1. The following error occurs when pod Trunk pushes:
[!]  Source code for your Pod was not accessible to CocoaPods Trunk. Is it a private repo or behind a username/password on http?Copy the code

There are many possible causes of this error, CocoaPods issues

If HTTP is used for spec.source, HTTP address authentication fails or anti-theft links are added. The address can be HTTP or HTTPS.

  1. The following error occurs when pod Trunk pushes:
[!]  The spec did not pass validation, due to 1 warning (but you can use `--allow-warnings` to ignore it).Copy the code

Solutions:

Resolve the warning or simply ignore it

$ pod trunk push xxx.podspec --allow-warnings
Copy the code
  1. Error: Pod Search XXX
[!]  Unable to find a pod with name, author, summary, or description matching `xxx`Copy the code

Solutions:

$ rm ~/Library/Caches/CocoaPods/search_index.json
$ pod update
Copy the code
  1. The following error occurs when pod Trunk pushes:
[!]  Validating podspec -> xxx - ERROR | [iOS] unknown: Encountered an unknown error ([!]  /usr/local/bin/git clone https://github.com/ /var/folders/y7/n65v0jv56m1_7cnw2_rgkw_40000gn/T/d20200730-14094-1fdff6i --template= --single-branch --depth 1 --branch 4.0.1 Cloning into '/var/folders/y7/n65v0jv56m1_7cnw2_rgkw_40000gn/T/d20200730-14094-1fdff6i'... error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60 fatal: The remote end hung up unexpectedly fatal: early EOF fatal: unpack-objects failed ) during validation. [!]  The spec did not pass validation, due to 1 error.Copy the code

Solutions:

Online query is said to tag, repeat several times are invalid, violent solution -> delete remote warehouse resubmit -> success.

  1. The following error occurs when pod Trunk pushes:
[!]  Authentication token is invalid or unverified. Either verify it with the email that was sent or register a new session.Copy the code

Solutions:

① Query registration information

$ pod trunk me
Copy the code

② Pod Trunk Register mailbox name

$ pod trunk register [email protected] yusheng
​
Copy the code

③ Check the email, click the email link, and resubmit.