CocoaPods日常使用

Pod命令

升级CocoaPods

sudo gem install cocoapods 

pod 更新慢的解决方案

在install或update后面加上这几个参数即可

pod install --verbose --no-repo-update
pod update --verbose --no-repo-update

Podfile 文件配置

代码来源

# open source
source 'https://github.com/CocoaPods/Specs.git'
# my work
source 'https://github.com/xxx/Specs.git'

# 平台版本信息
platform :ios, '9.0'
use_frameworks!

target 'ZMImageBrowser_Example' do
  #主程序需要引入的三方库
  pod 'ZMImageBrowser', :path => '../'
  pod 'MBProgressHUD'

  #Test 需要引入的三方库
  target 'ZMImageBrowser_Tests' do
    inherit! :search_paths

    pod 'FBSnapshotTestCase' , '~> 2.1.4'
  end
end


创建私有库

创建Pods工程

pod lib create ZMImageBrowser

控制台日志及选项如下:


私有库podspec配置

Pod::Spec.new do |s|
  s.name             = 'ZMImageBrowser'
  s.version          = '0.1.0'
  s.summary          = 'A short description of ZMImageBrowser.'
  s.description      = <<-DESC
TODO: Add long description of the pod here.
                       DESC

  s.homepage         = 'https://github.com/z251257144/ZMImageBrowser'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'z251257144' => 'zmsoul@126.com' }
  s.source           = { :git => 'https://github.com/z251257144/ZMImageBrowser.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

  s.ios.deployment_target = '9.0'

  s.source_files = 'ZMImageBrowser/Classes/**/*'
  
  # s.resource_bundles = {
  #   'ZMImageBrowser' => ['ZMImageBrowser/Assets/*.png']
  # }

  # s.public_header_files = 'Pod/Classes/**/*.h'
  
  s.frameworks = 'UIKit', 'ImageIO', 'QuartzCore', 'AssetsLibrary', 'MediaPlayer'
  
  s.dependency 'MBProgressHUD'
  s.dependency 'DACircularProgress'
  s.dependency 'SDWebImage'
  
end