How to make a private warehouse

Before we can do componentization, we have to do how to make the private repository and the reference between the private repositories.

Private repository => Private repository => Private Components

Create a remote Spec repository

The purpose of this repository is to store private library spec indexes

2. Create a local index library and associate it with a remote index library

  • Add the spec repository locally
Pod repo add [Spec address]Copy the code

For example: pod repo add PrivatePod [email protected]: XXXX/PrivatePod git

  • To view
pod repo list
Copy the code
PrivatePod
- Type: git (master)
- URL:  [email protected]:xxxx/PrivatePod.git
- Path: /Users/aba/.cocoapods/repos/PrivatePod
Copy the code
  • Removing a local indexPrivatePod
pod repo remove PrivatePod
Copy the code

3. Commit the private component

  • To the component directory
CD Component file pathCopy the code
  • Add tags
Git tag-a 0.0.1 -m 'release 0.0.1'Copy the code
  • Upload to the remote end
git push origin --tags
Copy the code
  • Commit the index file to the remote index library
Pod repo push [Spec repository name] [private library index file name (.podSpec)]Copy the code

For example: Pod repo push PrivatePod KJCategories. Podspec –allow-warnings

Ignore warnings and add –verbose –allow-warnings after them

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

When CTMediator is componentized, the Swift publishing component must carry –use-modular-headers

For example, pod repo push PrivatePod BaseModulization. Podspec –verbose –allow-warnings –use-libraries — use-module-headers

  • Podspec Parameter description
--help displays the help banner of the specified command --verbose displays more debugging information --silent displays all information --allow-warnings ignores warnings --use-libraries Install using static libraries --use-modular headers OC with Swift must add --skip-import-validation skips whether pod can be imported --skip-tests skips building and running tests during validation --use-json Before pushing it to the REPO, convert the PodSpec to JSON --swift-version= version the SWIFT_VERSION that should be used when tagging the specification. This takes precedence over the Swift version or as specified in the specification. Swift version,Copy the code
  • Update the index after success
pod setup
Copy the code

At this point, the private Pod and production are almost complete

Pod private component use

  • The first: link address use
pod 'KJCategories',:git => 'https://github.com/yangKJ/KJCategories.git'
Copy the code
  • Second: Change the Source
source '[email protected]:xxxx/PrivatePod.git'
Copy the code
  • The content of the Podfile is as follows:
# Uncomment the next line to define a global platform for your project source 'https://github.com/CocoaPods/Specs.git' Source '[email protected]: XXXX/PrivatePod. Git # private index platform: ios, Version '10.0' # Is the lowest supported version of 's.iso. Deployment_target' in all CocoaPods inhibit_all_warnings! use_frameworks! ## def modules_Pods ## pod 'KJCategories' end :path => '.. /Modules/DiscoverModules' ## My module pod 'MineModules', :path => '.. /Modules/MineModules' end target 'MainProject_Example' do # Comment the next line if you don't want to use dynamic ## Main tabBar pod 'AppMain', :path => '.. / ## Mediator', :path => '.. /Mediator' ## Mediator', :path => '.. /FeatBox' private_pods modules_pods # Pods for HomeDemo end target 'MainProject_Tests' do inherit! :search_paths endCopy the code

Pod fast upload to private library

  • Normally we upload to the private library through
Pod repo push [Spec repository name] [private library index file name (.podSpec)]Copy the code

  • Because the above method is time-consuming, you can use the following method:

    • Make sure thatpodspecFile correct,pod lib lint --allow-warnings(Skip this step if you are sure your PodSpec is ok)
    • Clone private warehouse to local,Git Clone repository address
    • About to upload librarypodspecFiles are stored in a private repository in proper format
      • Ex: the folder name is 0.0.2hundreds
    • Then upload the commit code to the remote repository as normal
    • Add a local label,Git tag-a 0.0.1 -m 'release 0.0.1'
    • Upload the label to the remote end,git push origin --tags
    • Finally update the local private libraryrepoThe index,pod repo update PrivatePod
  • The general hierarchical structure is as follows:

Common Mistakes

  • Error: Remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
    • Solution: Change the Source of the KJCategories. Podspec file to the SSH address
s.source = { 
  :git => '[email protected]:yangKJ/KJCategories.git', 
  :tag => s.version.to_s 
}
Copy the code
  • Failed to open TCP connection to github.com:443

    • Solution: Open it in Safarihttps://github.com/CocoaPods/Specs.git
  • 3. Error reporting: Your configuration specifies to merge with the ref ‘refs/heads/master’ from the remote, but no such ref was fetched.

    • Solution: Since [Spec repository] is an empty repository, you need to put something in it, such as readme.md
  • 4, 错 误 : Specs were satisfying theKJCategories dependency were found, but they required a higher minimum deployment target.) during validation.

    • Cause analysis: Three parties depend on the libraryKJCategoriesThe lowest version supportedS.i OS. Deployment_target = '9.0', and the lowest supported version specified in this library’s PodSpec file is lower than that of the tripartite dependent library
    • Solution: Change the minimum supported version of this library to be greater than or equal to the third party dependent library

The last

  • Attached is a development acceleration library, simply so convenient. 🎷
  • Demo address 🎷 like the bosses can point a small star. Portal – KJCategories