Cocoapods简单集成使用

安装cocoapods 

sudo gem install cocoapods

升级/安装

sudo gem install cocoapods --pre

安装权限报错

sudo gem install -n /usr/local/bin cocoapods --pre

查看版本号

pod --version

使用Cocoapods

cd 到项目根目录,初始化cocoapods会自动创建 Podfile 文件

pod init

可以使用文本编辑器打开根目录下新建的 Podfile 文件, 添加需要使用的第三方库,例如添加以下内容:

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

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

  pod 'AFNetworking', '~> 4.0'
  pod 'SDWebImage', '~> 5.0'

  # Pods for Demo02

  target 'Demo02Tests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'Demo02UITests' do
    # Pods for testing
  end

end

下载安装配置的第三方库

pod install

项目根目录下会创建  项目名.xcworkspace文件 合 pods 文件夹

Xcode重新打开 项目名.xcworkspace 文件,到这里cocoapods使用基本完成。

升级第三方库

pod update

如果以上指令运行比较耗时, 可使用下面的指令来跳过本地仓库的升级

pod install --verbose --no-repo-update  
pod update --verbose --no-repo-update  
或者  
pod install --no-repo-update  
pod update --no-repo-update

查看某个第三方库的可用版本

pod search AFNetworking

你可能感兴趣的:(cocoapods,xcode,ios,前端)