美文网首页
CocoaPods的使用

CocoaPods的使用

作者: LevinLuo | 来源:发表于2017-02-26 02:37 被阅读0次

    CocoaPods使用教程

    一丶安装

    简单来说CocoaPods就是用来统一管理项目中需要使用到的第三方库

    首先,Mac电脑必须要有Ruby环境

    Mac OS本身自带Ruby,但还是更新一下保险!

    1.查看Ruby当前版本: 打开终端输入 ruby -v

    Paste_Image.png

    2.更新Ruby
    这里要把Ruby镜像指向https://gems.ruby-china.org/
    (避免被墙,taobao的也可以https://ruby.taobao.org/
    )
    终端命令
    首先移除系统Ruby镜像指向
    gem sources --remove https://rubygems.org/
    添加我们要替换的Ruby镜像指向
    gem sources -a https://gems.ruby-china.org/
    检查替换的镜像指向是否成功
    gem sources -l

    Paste_Image.png

    3.下载安装CocoaPods
    终端输入:sudo gem install cocoapods

    二丶使用

    1. 首先使用xcode新建一个项目
    Paste_Image.png
    1. 终端中cd到项目目录并建立一个Podfile文件
      a.创建Podfile:vim Podfile
      b.保存Podfile:(:wq)
      此时你就能在项目目录下看到多出来的Podfile文件
    Paste_Image.png

    c.为项目配置pod: pod install

    1. 用文本编辑器打开Podfile并输入
    Paste_Image.png

    然后终端输入:pod install,最后项目目录就会变成

    Paste_Image.png
    1. 双击xcworkspace文件
    Paste_Image.png

    相关文章

      网友评论

          本文标题:CocoaPods的使用

          本文链接:https://www.haomeiwen.com/subject/jsfowttx.html