IOS make pod private library detailed tutorial

Cocoapods official website address

1. Create a POD library

You need to create two remote repositories, one for private repositories and one for project repositories

  • 1. Create a private libraryhttps://gitee.com/XXSpec.git
  • 2. Create a project database

Plan a

  • createpodlibrary
pod spec create PodName
Copy the code
  • The editorspecFile and execute
pod spec lint PodName.podspec
Copy the code

Scheme 2

  • Direct use ofcocoapodscreate
pod lib create PodName
Copy the code
  • Or specifyclone urladdress
Pod lib create PodName --template-url=' clone url'Copy the code
  • Then enter and execute
What platform do you want to use?? [ iOS / macOS ]
> iOS

What language do you want to use?? [ Swift / ObjC ]
> ObjC

Would you like to include a demo application with your library? [ Yes / No ]
> YES

Which testing frameworks will you use? [ Specta / Kiwi / None ]
> None

Would you like to do view based testing? [ Yes / No ]
> No

What is your class prefix?
> ZX
Copy the code

2. Add code and images

  • in~/PodName/PodName/Classes Add the code you want to publish under the folder
  • in~/PodName/PodName/Assets Add the required images under the folder

3. Edit podSpec information

  • podspecThe document describes one in detailpodLibrary versions of various information.
Pod: : Spec. New do # | s | Pod library name s.n ame = 'PodName' # Pod library version s.v ersion = '0.1.0 from' # Pod outlining the Pod when the search display s.s ummary = 'A Short description of PodName.' # description of PodName = << -desc TODO: Add long description of the pod here. DESC # Or validation is not by Sheldon horowitz omepage = 'https://github.com/zhaixingxing/PodName' # open source licenses There must be s.l icense = {: type = > 'MIT, :file => 'LICENSE'} # author info # Pod screenshots, support single or array, mainly suitable for THE Pod library UI class. # s.createshots = [' createshots ',' createshots'] s.thor = {'zhaixingxing' => '[email protected]'} # support HTTP and HTTPS. It is best to use HTTPS s.s ource = {: git = > 'https://github.com/zhaixingxing/PodName.git', To_s} # multimedia introduction address # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>' # Description document address # Spyware doctor ocumentation_url = 'http://www.example.com/docs.html' # support version s.i OS. Deployment_target = '9.0' version of swift # # support S.wift_version = '5.0' # Whether to use static libraries. If podfile specifies use_frameworks! # s.setatic_framework = true ARC # s.equires_arc = true # resource file s.source_files = 'PodName/Classes/**/*' # s.source_files = 'Classes/**/*.{h,m}', 'More_Classes/**/*.{h,m}' # resource library files # s.resource_bundles = {# 'PodName' => ['PodName/Assets/*'] # s.frameworks = 'UIKit', # s.endored_frameworks = ['Module/*.framework'] # s.endored_library = 'Module/Classes/SDK/*. A '# dependent.a multiple separated by commas. Libraries = ['xml2.2','sqlite3.0'] # dependent third-party libraries # 'AFNetworking', '~> 2.3' # s.dependency 'SDWebImage' # s.public_header_files = 'Pod/Classes/**/*.h' # specify private header files # S.private_header_files = 'Pod/Classes/**/*.h' # Custom prefix files default to system header files # s.prefix_header_file = false # s.prefix_header_file = 'iphone/include/prefix. PCH' # PCH file header file is added to the system Multiple use commas # supachai panitchpakdi refix_header_contents = '# import < UIKit/UIKit. H >', '# import "Test. H"' end # sub-modules s.s ubspec 'TestSub do | | ss # module file, Source_files = 'podName/Classes/TestSub/**/*' endCopy the code
  • File directory structure

4. Create a Cocoapods account

  1. Check whether an account has been created
pod trunk me # [!]  You need to register a session first.Copy the code
  1. Registered account
Pod Trunk register address 'user name' --description=' description 'Copy the code
  • After registration, go to the mailbox to open the email and activate the verification registration

  • verify

Pod trunk me # output - Name: user Name - Email: Email XX - Since: date - Pods: XXXX - Sessions: XXXXCopy the code

5 Verify that the POD passes

  1. Local validation
Pod lib lint podName # pod lib lint --verbose Displays detailed detection procedures # pod lib lint --allow-warnings allow warningsCopy the code
  1. Local and remote authentication
pod spec lint podName #pod spec lint podName \ --verbose --use-libraries --allow-warnings -- \ = 'https:// private library sources. Git, https://github.com/CocoaPods/Specs.git'Copy the code

6. Submit pod

  • submit
Pod repo push private library podName. Podspec --verbose --use-libraries --allow-warningsCopy the code
  • Verify after successful submissionpod
If pod search podName fails, delete pod cache rm ~/Library/Caches/CocoaPods/search_index.jsonCopy the code

7. To update the pod

  1. Changing the Version numberS.v ersion = 'while'
  2. Upload the code to the remote repository
  3. playtagIs equal to thewhile
  4. validationpodAnd submit

Appendix PodSpec parameters

  • --allow-warnings: Ignore warnings
  • --verbose: Displays more debugging information
  • --silent: Displays all information
  • --use-libraries: Using static library installation
  • --use-modular-headers:OCwithSwiftRemixes must be added
  • --skip-import-validationSkip verifying that the POD can be imported
  • --skip-testsSkip building and running tests during validation
  • --use-json: Pushes it torepoBefore,podspecconvertJSON
  • --swift-version=VERSION: should be used when marking specificationsSWIFT_VERSIONThis takes precedence over what is specified in the specificationSwiftVersion or. SwiftVersion of the article
  • --help: Displays a help banner for the specified command