Old hands can skip it completely, and say nothing more…

Installed a.

Open the Terminal and enter the command

sudo gem install cocoapods

Still message cannot install can try

sudo gem install cocoapods --user

twopodCommand to use

  • pod init
    • Run in the root directory of the project to generate a copyPodfilefile
    • Self-createdPodfileFile, do not use this command
  • pod deintegrate
    • Run in the project root directory to remove the projectcocoapodsAll Settings related to dependency management (*.xcodeprojThe inside of thebuild settingRelated Settings), generally not used
  • pod install
    • In accordance with thePodfile(version number, repository index source…) Install the dependency libraries, andgenerate/update Podfile.lock(Record dependency library dependencies, version numbers, repository index sources…)
  • pod update
    • In accordance with thePodfileSet and combinePodfile.lock(Required) Version upgrade

General use

  1. Pod init # Initializes a Podfile
  2. PodfileAdd tripartite library to file
  3. Pod Install # The project installs the dependency library for the first time
  4. Pod Update # Daily version updates according to the rules set by the Podfile

tip

  • pod initandpod updateEach run is updated firstWarehouse index sourceData, slightly time-consuming, can be changed to manual update
    • You can add parameters later--no-repo-update, you canThe installation/updateWhen not updateWarehouse index source
      • pod install --no-repo-update
      • pod update --no-repo-update
    • Manual updateWarehouse index source
      • pod repo update

3. Podfile

A template generated by pod Init

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'iOSDemo' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for iOSDemo

end
Copy the code
  • platform: Set the platform and version number compatible with the project
  • target: atargetDependency library installation configuration
    • Fill in the dependency libraries and configurations that need to be installed
      • Pod {name of dependent library}, such aspod 'AFNetworking'.Pod 'AFNetworking' ~ > 1.0
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'iOSDemo' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for iOSDemo
  pod 'AFNetworking'
end
Copy the code

Depend on library version Settings

  • = 0.1Version 0.1
  • > 0.1Any version greater than 0.1
  • > = 0.1Anything greater than or equal to version 0.1
  • < 0.1Any version less than 0.1
  • < = 0.1Anything less than or equal to version 0.1
  • ~ > 0.1.2Versions 0.1.2(included) to 2.0.0(not included)
  • ~ > 0.1.3 - beta. 0Beta version 0.1.3, and release 0.1.3(inclusive) to 2.0.0(not included)

Version semantic description (interested can understand)

The Semantic Versioning: semver.org/lang/zh-CN/ RubyGems Versioning Policies: guides.rubygems.org/patterns/#s…

Refer to the link

  • Website: cocoapods.org

The original link