zoukankan      html  css  js  c++  java
  • iOS 如何通过CocoaPods添加第三方框架

    一  先安装Ruby环境:

      http://ruby-china.org/wiki/install_ruby_guide

      在安装的时候,若是出现:

        1.You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

          就在命令前加一个sudo获得管理员权限,eg: sudo gem install bundler

     

        2.Error installing rails:activesupport requires Ruby version >= 2.2.2.

          macOS 自身已经安装了 Ruby 了,版本应该比较低的,直接按照上面命令安装,会提示 Ruby 版本不够的错误信息,可以参考http://blog.csdn.net/lissdy/article/details/9191351进行更新,要走注意输入版本号的正确性,eg:rvm install 2.3是正确的,而rvm install 2.3.0是错误的

     

    二 安装CocoaPods:

      $ sudo gem install cocoapods

      1.当pod setup 进入Setting up CocoaPods master repo 等待的时候表示正在下载了,此时你可通过新开一个终端窗口,输入"cd ~/.cocoapods/"命令行跳到cocoapods文件夹内,执行"du -sh *"查看正在下载的文件夹的大小

      $ pod search AFNetworking  检查是否成功安装CocoaPods

            

             

    三 使用CocoaPods:

      1.直接将根目录拖拽进命令行窗口即可

        cd + 文件路径

      2.创建Podfile文件(不能使用文本编辑编辑内容)

         vim Podfile

        1)The dependency `AFNetworking (~> 3.1.0)` is not used in any concrete target.

          

            解决方式为将Podfile 内填写格式改为如下: (TestThirdParty 改为自己项目名)

            platform :ios, '8.0'

            use_frameworks!

            target 'TestThirdParty' do

            pod 'AFNetworking', '~> 2.6'      

            //可以连续pod多个第三方 

            // pod 'B','版本'...                     

            end

        2)Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.
            
    解决办法为不要使用文本编辑去编辑Podfile,使用Xcode编辑,或者使用终端敲命令去编辑。或者输入格式错误,没输入运行版本:$platform:ios, ‘9.0‘

      3.根据Podfile文件安装第三方框架

         pod install

            

            

         

  • 相关阅读:
    NanoProfiler
    NanoProfiler
    Open Source Cassandra Gitbook for Developer
    Android Fragment使用(四) Toolbar使用及Fragment中的Toolbar处理
    Android Fragment使用(三) Activity, Fragment, WebView的状态保存和恢复
    Android Fragment使用(二) 嵌套Fragments (Nested Fragments) 的使用及常见错误
    Android Fragment使用(一) 基础篇 温故知新
    Set up Github Pages with Hexo, migrating from Jekyll
    EventBus源码解析 源码阅读记录
    Android M Permission 运行时权限 学习笔记
  • 原文地址:https://www.cnblogs.com/roxy/p/5947003.html
Copyright © 2011-2022 走看看