当前位置:网站首页>② Cocoapods principle and podspec file uploading operation

② Cocoapods principle and podspec file uploading operation

2022-06-23 05:06:00 Black code brother

cocoapods principle

Gem It's a management Ruby Standard packages for libraries and programs , It passes through Ruby Gem( Such as http://rubygems.org/ ) Source 、 install 、 Upgrade and uninstall packages , It's very convenient .

Can pass pod --versionn see pod Version number
Can pass ruby -v see ruby Version number
Can pass gem -v see gem Version number

pod Basic operation

  1. View the third-party framework repository source pod repo
  2. Remove warehouse source pod repo remove master
  3. Add warehouse source pod repo add master http://git.oschina.net/akuandev/Specs.git
  4. initialization ( Download all the third-party framework information in the server , Cache to local computer ) pod setup
  5. pod search Framework keywords — Cached from local " Third party framework description information " Retrieved... From the generated retrieval file Information about the relevant framework
  6. Delete cocoapods Index file rm ~/Library/Caches/CocoaPods/search_index.json
  7. establish Podfile file , Go into your own project ( First level directory )
    • Podfile The function of documents ?
      answer : It's really just using ruby Grammatically written “ The framework depends on the description file ”; Just tell cocoapods Which frameworks need to be downloaded and integrated
    • Create command pod init
  8. Install the frame pod install
     Insert picture description here

 Insert picture description here

cocoapods Schematic diagram :
 Insert picture description here

sepcs
Remote index library

`pod setup``
In fact, it is to download the remote index library to the local index library

If we pod install after , Then download the three parties to the project .
When we use these source codes again in another project , then install after , It will be soon , Because a local backup has been made

When we first pod search It's going to be slow , Because it will be downloaded again , Then put it in the cache , So it will be much faster to perform this operation next time . The following figure shows the cache path
 Insert picture description here

 Insert picture description here

Create a remote library , And make PodSpec adopt trunk push podspec file

  • First step , Upload items to github, And label it

    • See my first componentization article for specific operations git Basic use
    • git push origin master
    • git tag '1.0.0'
    • git push --tags
  • The second step , register trunk

    • pod trunk register 157******[email protected] 'wanggang' --verbose
      –verbose Parameter is used to output debugging information during registration
    • After registration, the email will be sent to you , Go in and check .
  • The third step , Configure and upload the framework PodSpec file

    • principle

      • PodSpec file Describe your framework information : author , edition , Download address, etc
      • pod search Search framework , It is based on the information in this
      • Be careful : Generally, the name of this file is consistent with the project name
      • Create command :pod spec create File name
      • I'll do it myself :
        $ cd /Users/liuxitong/Desktop/testLib
        $ pod spec create testLib
        This creates , As shown in the figure :
         Insert picture description here
    • PodSpec File format

      • Can be downloaded by cocoapods Description information in the management framework , You can also check on the official website The website links
      • pod spec lint podspec file
      • If the check fails , If you find any problems, you can modify them podspec Corresponding place .
      • some podspec Field interpretation in :
        spec.source_files: Which tag files to get from the address Wildcards denote directories , namely classes Directory in folder
        spec.source_files = “Classes”, "Classes/
        /*.{h,m}"
    • adopt trunk push podspec file

      • pod trunk push
      • I'll do it here pod trunk push testLib.podspec
        So we will PodSpec Upload succeeded , And then we were in cocoapod You can also add our new third-party library .
      • This method is actually uploading the description file to cocoapods stay github In the warehouse above , Warehouse address
      • Then you need to wait for the review , Follow pull request equally , The author's consent is required
  • Step four , Update local pod Third party framework information data source
    pod setup

  • Step five , Use pod search Command to search your own frame , If you can search , Then it means that the audit has passed

原网站

版权声明
本文为[Black code brother]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206222320066378.html