一个专门记录各种姿势的地慌!!

用 CocoaPods 安装 LeanCloud SDK

- 适用于 swift

- 官方文档 https://leancloud.cn/docs/sdk_setup-swift.html

说明:

    CocoaPods 是 iOS 开发中最常用的第三方类库管理工具

    LeanCloud 是目前国内非常不错的一站式解决方案,包括:数据存储、用户管理、消息推送、应用统计、社交分享、实时聊天等服务


安装 CocoaPods :

    安装 CocoaPods 需要 Ruby 运行环境的支持,好在 Mac 自带 Ruby,但是版本太低,不符合 CocoaPods 的安装要求,所以我先升级 Ruby 。

1、安装 RVM(用 RVM 来更新 Ruby)

    终端:curl -L get.rvm.io | bash -s stable

    终端:source ~/.bashrc  

    终端:source ~/.bash_profile 


    测试是否安装正常

    终端:rvm -v


    查看当前ruby版本  

    终端:ruby -v 


    列出已知的ruby版本  

    终端:rvm list known

     

    安装ruby 2.3  

    终端:rvm install 2.3

    

    最后查看是否安装成功

    终端:ruby -v 


2、安装 CocoaPods

    由于主站在国外,所以先更换为淘宝镜像

    终端:gem sources --remove https://rubygems.org/

    终端:gem sources -a https://ruby.taobao.org/

    

    查看是否成功

    终端:gem sources -l

    *** CURRENT SOURCES ***

    https://ruby.taobao.org


    安装 CocoaPods

    终端:sudo gem install cocoapods

    等几分钟就安装好了


安装 LeanCloud SDK :

    在项目根目录下创建一个名为 Podfile 的文件(无扩展名),并按需添加以下内容:

    use_frameworks! # LeanCloud Swift SDK can only be integrated as framework.


    target '项目名称' do

    pod 'LeanCloud', :git => 'git@github.com:leancloud/swift-sdk.git', :tag => '0.0.1.beta'

    end


    对项目点右键,选择 Open with External Editor ,然后在打开的终端中 cd .. 到项目根目录

    执行命令 pod install --verbose 安装 SDK。如果本地安装过最新版本的 SDK,则可执行 pod install --verbose --no-repo-update 来加快安装速度

 
评论
© spume - code | Powered by LOFTER