Cocoapods原理与使用

Cocoapods使用

  • 安装Cocoapods
  1. 更新自带Ruby
sudo gem update —system
  1. 更换源
gem sources —add [https://gems.ruby-china.com/](https://gems.ruby-china.com/) —remove [https://rubygems.org/](https://rubygems.org/)
gem sources -l 进行检查
  1. 安装Cocoapods
sudo gem install cocoapods 如果出错执行 sudo gem install -n /usr/local/bin cocoapods
pod —version 查看cocoapods 版本号
pod setup 安装
  • 版本回退
  1. 查找pod安装路径并删除
which pod
sudo rm -rf /usr/local/bin/pod
  1. 查看gems中本地程序包并删除
gem list
sudo gem uninstall cocoapods -v 1.6.1
sudo gem uninstall cocoapods-core -v 1.6.1
  1. 安装制定版本的cocoapods
sudo gem install cocoapods -v 1.5.3
  • 制作一个Pod
  1. pod lib create XUAlertView
  2. 写pod库内容
  3. 编写podspec、readme.md
  4. 打标签:
1.本地操作: git tag “0.1.0” (删除:git tag -d "0.1.0”)
2.远端操作: git push —tags (git push origin :refs/tags/0.1.0)
  1. pod spec lint xxxxxx.podspec
  2. pod trunk push xxxxxxx.podspec
podspec内容
Pod::Spec.new do |s|
    s.name            = 'XUAlertView'
    s.version          = '0.1.0'
    s.summary          = 'XUAlertView'
    s.description      = <<-DESC
    Qingting iOS XUAlertView Framework
    DESC
    s.homepage         = '[https://github.com/xupeng48/xualertview](https://github.com/xupeng48/xualertview)'
    s.license          = { :type => 'MIT', :file => 'LICENSE' }
    s.author           = { 'xupeng' => '[xupeng@qingting.fm](mailto:xupeng@qingting.fm)' }
    s.source           = { :git => '[https://github.com/xupeng48/xualertview.git](https://github.com/xupeng48/xualertview.git)', :tag => s.version.to_s }
    s.ios.deployment_target = '8.0'
    s.requires_arc = true
    s.public_header_files = 'XUAlertView/Classes/**/*.h'
    s.source_files = 'XUAlertView/Classes/**/*'
    s.resource_bundles = {
        'XUAlertView' => ['XUAlertView/Assets/images/*.png’]
    }
end
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容