1. Create the local Pods library

Pod lib create [private library name]Copy the code

2. Generate the local Pods file

------------------------------ To get you started we need to ask a few questions, this should only take a minute. If this is your first time we recommend running through with the guide: - https://guides.cocoapods.org/making/using-pod-lib-create.html ( hold cmd and double click links to open in a browser. Select What platform do you want to use?? [iOS/macOS] > iOS // Select What language do you want to use?? [Swift / ObjC] > ObjC Would you like to include an application with your library [Specta/Kiwi/None] > None Would you like to do view based frameworks [Yes/No] > Yes // What is your class prefix? > XYCopy the code

3. Replace the ReplaceMe file

Replace replaceme.m with your own development file

4. Edit the spec index file

Pod: : Spec. New do | s | / / project name s.n ame = 'BaseUtility' / / version number s.v ersion = '0.1.0 from' / / synopsis overview s.s ummary = 'basic component library / / description Spyware doctor escription = < < - DESC base, the category, the tools DESC / / making project web page address Sheldon horowitz omepage = 'https://github.com/XueYangLee/BaseUtility' // License file s.license = {:type => 'MIT', :file => 'LICENSE'} // code author s.thor = {'[email protected]' => '[email protected]'} 'https://github.com/XueYangLee/BaseUtility.git', To_s} // Supports the lowest version of S.ios. deployment_target = '10.0' //! Important! The content of the file you want to upload to cocoapods. Source_files = 'BaseUtility/Classes/**/*.{h,m}' There is no neglectable s.files = {'BaseUtility' => ['BaseUtility/Assets/**/*.*']} // header file s.public_header_files = 'BaseUtility/Classes/**/*.h' // framework # s.frameworks = 'UIKit', 'MapKit' // referenced third party library s.dependency 'AFNetworking' endCopy the code

5. Create remote Spec repository and private repository code repository

  • 1. Create a remote Spec repository PrivateSpecs to store the private Spec index

Create a README file when creating the Spec repository. Otherwise, an error message will be displayed: Your Configuration specifies to merge with the ref

  • 2. Create private repository code remote repository to store code

6. Add the spec repository locally

Pod repo add [Spec address]Copy the code

Example: pod repo add PrivateSpecs [email protected]: XueYangLee/PrivateSpecs git

Check whether local verification is added successfully

pod lib lint 
pod lib lint --allow-warnings --verbose
Copy the code

The remote calibration

pod spec lint
Copy the code

To view

pod repo
Copy the code

Locally view ~/. Cocoapods /repos

Deleted replacing the POD RepO

Pod repo remove [Spec repository name]Copy the code

7. Remotely submit index files

Pod repo push [Spec repository name] [private library index file name (.podSpec)]Copy the code

Ignore the warning

Pod repo push [Spec repository name] [private library index file name (.podspec)] --verbose --allow-warningsCopy the code

Use use-libraries to add third-party libraries that contain static packages

Pod repo push [Spec repository name] [private library index file name (.podspec)] --verbose --use-libraries --allow-warningsCopy the code
Pod repo push [name] Spec warehouse [private library index file (. Podspec)] - sources = '[address] Spec private library, https://github.com/CocoaPods/Specs.git' --use-libraries --allow-warningsCopy the code

Example: Pod repo push PrivateSpecs BaseUtility. Podspec –verbose –use-libraries –allow-warnings


use

  • Call the remote private Pods library
pod 'BaseUtility',:git => 'https://github.com/XueYangLee/BaseUtility.git'
Copy the code
source '[email protected]:XueYangLee/PrivateSpecs.git'
pod 'BaseUtility'
Copy the code
  • Call the local private library

Clone locally, create LocalLibs files locally in the project to store the local libraries and copy the private libraries into them

pod 'BaseUtility',  :path => './LocalLibs/BaseUtility'
Copy the code

This can be modified and used in the project Development Pods folder


Common errors in submission

  • 1. Error: [!] The repoMySpecs at . /.. /.. /.cocoapods/repos/ZZPublicSpecs is not clean

Solutions:

Remove local private index libraries: pod repo remove ZZPublicSpecs

2 add index of local private libraries: pod repo add ZZMakeSpecs https://github.com/UserZhangXiaoZhe/ZZMakeSpecs.git

Pod repo push ZZMakeSpecs zzMakeavPlayer. podspec –allow-warnings

  • 2. An error: Your configuration specifies to merge with the ref ‘refs/heads/master’ from the remote, but no such ref was fetched.

The readme.md file was not created when the remote index library was created, which is an empty repository. Keep reporting errors in update index step at commit time. After searching the Internet for a long time, I could not find the reason. Finally, I rebuilt a repository and added the readme.md file. To submit the index library is ok. I copied the readme. Md file and submitted it, and then went to commit the index library. So when you create an index, you can’t create an empty repository that has everything in it but nothing in it.

Solution: Put anything in storage.

  • 3. Error: Failed to open a TCP connection to raw.githubusercontent.com: 443

Go to safari and execute.

  • Failed to push some refs to

Do the code merge with the following command

git pull --rebase origin master
Copy the code

You can see the readme.md file in your local file

Then run Git push Origin master to push

  • 5. Error: [!] Thexxx.podspecspecification does not validate. But there is no ERROR
pod repo push --sources=https://github.com/UserZhangXiaoZhe/ZZMakeSpecs.git,https://github.com/CocoaPods/Specs.git ZZMakeSpecs ZZMakeFMDBManager.podspec  --use-libraries --allow-warnings
Copy the code
  • 6. An error [!] Unable to add a source with url “ named- 1.

Solution: add a path to all index libraries, with the official path

pod repo push --sources=https://github.com/UserZhangXiaoZhe/ZZMakeSpecs.git,https://github.com/CocoaPods/Specs.git ZZMakeSpecs ZZMakeFMDBManager.podspec
Copy the code

Common errors refer to article