`
我的专长叫做流浪
  • 浏览: 1930 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

如何使用CocoaPods管理第三方库

阅读更多
IOS 第三方管理库管理 CocoaPods
越来越多的SVN管理,越来越多的工程文件,我不能总是那么一个一个的把第三方库拖进去,我厌倦了拖拽和配置,我找到了替代方法--CocoaPods
英文好的可以直接读一下我参考的网页 http://www.raywenderlich.com/12139/introduction-to-cocoapods
不嫌我唠叨 我就自己慢慢敲
第一步:安装
一般在安装CocoaPods之前是要先配置Ruby环境的,但是如果你已经安装了xcode你就可以直接安装了,不需要配置Ruby环境了,因为可能xcode安装的时候已经配置好了。安装的时候可能需要更新Ruby版本信息就好了
CocoaPods是跑在Ruby的软件,安装可能需要几分钟,打开你的终端输入:
sudo gem install cocoapods(这个有时候需要等很久,如果想快点就用下面补充的办法)
补充一下:最近在给新机子安装时 发现 sudo gem install cocoapods 没有反应,看来又是被墙了,可以用淘宝的ruby镜像
在终端敲入
$ gem sources --remove https://rubygems.org/

等有反应后再敲入  $ gem sources -a http://ruby.taobao.org/

然后测试下是真的可以了么,敲入
$ gem sources -l
*** CURRENT SOURCES ***  http://ruby.taobao.org/

恩 好了  继续之前的安装步骤  sudo gem install cocoaPods~~ 就可以了

如果成功 会有一个 Successfully installed cocoaPods的提示 ,

有时候会出现xcode版本提示,可以从appStore上更新xcode.可能遇到下面的问题
Mac AppStore下载失败.解决办法:
我进终端输入defaults write com.apple.appstore ShowDebugMenu -bool true就好了

然后再输入前面说的安装命令安装,这时候可能会遇到这样的问题:
lanou$ sudo gem install cocoapods
Password:
Building native extensions.  This could take a while...
[!] You are using the prebuilt binary version of the xcodeproj gem.

CHANGELOG:

## 0.29.0
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.28.0...0.29.0)
• [CocoaPods-core](https://github.com/CocoaPods/Core/compare/0.28.0...0.29.0)
• [cocoapods-downloader](https://github.com/CocoaPods/cocoapods-downloader/compare/0.2.0...0.3.0)

###### Breaking

* The command `podfile_info` is now a plugin offered by CocoaPods.
\ As a result, the command has been removed from CocoaPods. 
  [Joshua Kalpin](https://github.com/Kapin)
\ [#1589](https://github.com/CocoaPods/CocoaPods/issues/1589)

* JSON has been adopted as the format to store specifications. As a result
  the `pod ipc spec` command returns a JSON representation and the YAML
  specifications are not supported anymore. JSON specifications adopt the
  `.podspec.json` extension.
  [Fabio Pelosin](https://github.com/irrationalfab)
\ [#1568](https://github.com/CocoaPods/CocoaPods/pull/1568)

###### Enhancements

* Introduced `pod try` the easiest way to test the example project of a pod. 
  [Fabio Pelosin](https://github.com/irrationalfab)
  [#1568](https://github.com/CocoaPods/CocoaPods/pull/1568)

* Pod headers are now provided to the user target as a system
  header. This means that any warnings in a Pod's code will show
  under its target in Xcode's build navigator, and never under the
  user target. 
  [Swizzlr](https://github.com/swizzlr)
\ [#1596](https://github.com/CocoaPods/CocoaPods/pull/1596)

* Support LZMA2 compressed tarballs in the downloader. 
  [Kyle Fuller](https://github.com/kylef)
  [cocoapods-downloader#5](https://github.com/CocoaPods/cocoapods-downloader/pull/5)

* Add Bazaar support for installing directly from a repo. 
  [Fred McCann](https://github.com/fmccann)
\ [#1632](https://github.com/CocoaPods/CocoaPods/pull/1632)

* The `pod search <query>` command now supports regular expressions
  for the query parameter when searching using the option `--full`. 
  [Florian Hanke](https://github.com/floere)
\ [#1643](https://github.com/CocoaPods/CocoaPods/pull/1643)

* Pod lib lint now accepts multiple podspecs in the same folder. 
  [kra Larivain/OpenTable](https://github.com/opentable)
\ [#1635](https://github.com/CocoaPods/CocoaPods/pull/1635)

* The `pod push` command will now silently test the upcoming CocoaPods trunk
  service. The service is only tested when pushing to the master repo and the
  test doesn't affect the normal workflow. 
  [Fabio Pelosin](https://github.com/irrationalfab)

* The `pod search <query>` command now supports searching on cocoapods.org
  when searching using the option `--web`. Options `--ios` and `--osx` are
  fully supported.
\ [Florian Hanke](https://github.com/floere)
  [#1643](https://github.com/CocoaPods/CocoaPods/pull/1682)

* The `pod search <query>` command now supports multiword queries when using
  the `--web` option.
  [Florian Hanke](https://github.com/floere)
  [#1643](https://github.com/CocoaPods/CocoaPods/pull/1682)

###### Bug Fixes

* Fixed a bug which resulted in `pod lib lint` not being able to find the
  headers. 
  [Fabio Pelosin](https://github.com/irrationalfab)
  [#1566](https://github.com/CocoaPods/CocoaPods/issues/1566)

* Fixed the developer frameworks search paths so that
  `$(SDKROOT)/Developer/Library/Frameworks` is used for iOS and
  `$(DEVELOPER_LIBRARY_DIR)/Frameworks` is used for OS X. 
\ [Kevin Wales](https://github.com/kwales)
  [#1562](https://github.com/CocoaPods/CocoaPods/pull/1562)

* When updating the pod repos, repositories with unreachable remotes
  are now ignored. This fixes an issue with certain private repositories. 
  [Joshua Kalpin](https://github.com/Kapin)
\ [#1595](https://github.com/CocoaPods/CocoaPods/pull/1595)
  [#1571](https://github.com/CocoaPods/CocoaPods/issues/1571)

* The linter will now display an error if a Pod's name contains whitespace. 
  [Joshua Kalpin](https://github.com/Kapin)
  [Core#39](https://github.com/CocoaPods/Core/pull/39)
\ [#1610](https://github.com/CocoaPods/CocoaPods/issues/1610)
 
* Having the silent flag enabled in the config will no longer cause issues
  with `pod search`. In addition, the flag `--silent` is no longer supported
  for the command. 
\ [Joshua Kalpin](https://github.com/Kapin)
  [#1627](https://github.com/CocoaPods/CocoaPods/pull/1627)

* The linter will now display an error if a framework ends with `.framework`
  (i.e. `QuartzCore.framework`). 
  [Joshua Kalpin](https://github.com/Kapin)
  [#1331](https://github.com/CocoaPods/CocoaPods/issues/1336)
\ [Core#45](https://github.com/CocoaPods/Core/pull/45)

* The linter will now display an error if a library ends with `.a` or `.dylib`
  (i.e. `z.dylib`). It will also display an error if it begins with `lib`
  (i.e. `libxml`). 
  [Joshua Kalpin](https://github.com/Kapin)
  [Core#44](https://github.com/CocoaPods/Core/issues/44)

* The ARCHS build setting can come back as an array when more than one
  architecture is specified. 
  [Carson McDonald](https://github.com/carsonmcdonald)
  [#1628](https://github.com/CocoaPods/CocoaPods/issues/1628)

* Fixed all issues caused by `/tmp` being a symlink to `/private/tmp`.
  This affected mostly `pod lib lint`, causing it to fail when the
  Pod used `prefix_header_*` or when the pod headers imported headers
  using the namespaced syntax (e.g. `#import <MyPod/Header.h>`). 
  [kra Larivain/OpenTable](https://github.com/opentable)
\ [#1514](https://github.com/CocoaPods/CocoaPods/pull/1514)

* Fixed an incorrect path being used in the example app Podfile generated by
  `pod lib create`.
  [Eloy Durán](https://github.com/alloy)
  [cocoapods-try#5](https://github.com/CocoaPods/cocoapods-try/issues/5)


Successfully installed i18n-0.6.9
Successfully installed multi_json-1.8.4
Successfully installed activesupport-3.2.16
Successfully installed nap-0.6.0
Successfully installed json_pure-1.8.1
Successfully installed fuzzy_match-2.0.4
Successfully installed cocoapods-core-0.29.0
Successfully installed claide-0.4.0
Successfully installed cocoapods-downloader-0.3.0
Successfully installed rake-10.1.1
Successfully installed colored-1.2
Successfully installed xcodeproj-0.14.1
Successfully installed cocoapods-try-release-fix-0.1.1
Successfully installed escape-0.0.4
Successfully installed open4-1.3.0
Successfully installed cocoapods-0.29.0
16 gems installed
Installing ri documentation for i18n-0.6.9...
Installing ri documentation for multi_json-1.8.4...
Installing ri documentation for activesupport-3.2.16...

unrecognized option `--encoding'

For help on options, try 'rdoc --help'

使用gem –v 查看Ruby版本信息,如果版本很低(2.0.0以下)
那么
解决办法:sudo gem update –system 更新Ruby的版本。
好你的Ruby升级完了,可以重复之前的步骤了。




然后输入
pod setup

第二步:创建一个 Podfile 文件
继续在你的终端操作,先使用 cd 操作 进入你的项目目录例如 cd ~/desktop/HelloWord
在这个目录下创建文件
touch Podfile 然后回车继续输入 open -e Podfile 这时将直接打开一个空的文件先在这打开着不要管一会会处理的
第三步:搂一搂 搜索库
现在就需要找到你要的第三方库了,在终端里输入(以查找Reachability为例)
pod search Reachability
 终端会有和这个搜索结果相近的选项(示例如下)
-> KSReachability (1.3)
A better iOS & Mac reachability for a modern age.
- Homepage: https://github.com/kstenerud/KSReachability
- Source: https://github.com/kstenerud/KSReachability.git
- Versions: 1.3, 1.1, 1.0, 0.0.1 [master repo]
-> NPReachability (0.1.0)
Reachability without the suck.
- Homepage: https://github.com/Abizern/NPReachability
- Source: https://github.com/Abizern/NPReachability.git
- Versions: 0.1.0 [master repo]
-> Reachability (3.1.0)
ARC and GCD Compatible Reachability Class for iOS and OS X. Drop in
replacement for Apple Reachability.
- Homepage: https://github.com/tonymillion/Reachability
- Source: https://github.com/tonymillion/Reachability.git
- Versions: 3.1.0, 3.0.0, 2.0.5 [master repo]
第四步:在刚才打开的空白Podfile中加入你想要的,如
platform :ios  (这表示应用平台) pod 'Reachability', '3.1.0'   (库的名称  库的版本号)
(如果是多个就继续罗列即可):
platform :ios
pod 'JSONKit','1.4'
pod 'Reachability','3.0.0'
第五步:将这个写入数据的 Podfile保存后关闭
第六步:在终端输入
pod install
然后终端会有显示 示例:
[!] From now on use `name.xcworkspace'.
最后:是的 就像你看到的,你打开工程需要双击 .xcworkspace 这个工程,而不是之前的xcodeproj!!
 
OK 就这样了
最近使用时发现 FMDB找不到,一看版本号 pod --version 0.16.4  好老的版本,然后升级下
就是重新装一下   sudo gem install cocoapods   等操作完成 重新显示一下版本号 0.19.1   OK FMDB也有了~
 
 
分享到:
评论

相关推荐

    Ruby 环境安装,CocoaPods安装,轻松管理你的第三方库

    如何安装 Ruby和Ruby Gems 的运行环境,CocoaPods环境安装与使用?

    motion-cocoapods:通过CocoaPods将第三方库集成到RubyMotion for iOS OS X项目中

    motion-cocoapods允许RubyMotion项目与依赖管理器集成。 安装 $ [sudo] gem install motion-cocoapods 或者,如果您使用Bundler: gem 'motion-cocoapods' 设置 编辑Rakefile的RubyMotion项目并添加以下要求行: ...

    th-ios:一个app

    个人对文章和话题操作的记录,例如:关注,回复等等一、获取代码并且运行项目$ git clone https://github.com/chengfengjie/th-ios.git$ pod install项目用CocoaPods管理第三方库,如果您对CocoaPods还不够了解,请先...

    CocoaPods 安装与使用

    CocoaPods 是一个用于管理 iOS 项目依赖的开源工具。它允许开发人员轻松地添加、更新和删除第三方库和框架,从而简化了 iOS 开发过程中的依赖管理问题。以下是关于 CocoaPods 安装与使用的 PPT 资源描述。

    2016 cocoapods的安装和使用方法以及版本升级遇到的问题

    开发iOS项目不可避免地要使用第三方开源库,CocoaPods的出现使得我们可以节省设置和更新第三方开源库的时间,在iOS开发中经常会用到第三方库如AFNetworking,ASIHttpRequest等,在使用第三方库时,你除了要导数源码外...

    酒店管理毕业设计源码-Cocoapods-private-spec:ArepoforworkonspecrepoofCocoapods,Coc

    项目组件化、平台化是技术公司的共同目标,越来越多的技术公司推崇使用pod管理第三方库以及私有组件,一方面使项目架构更加清晰,一方面现有的工具Cocoapods提供了近乎完美的解决方案。这里我们来讨论一下如何在...

    CocoaPods:可可依赖管理器

    CocoaPods旨在改善第三方开源Cocoa库的参与度和可发现性。 这些项目目标影响并推动了CocoaPods的设计: 创建和共享库,并在您自己的项目中使用它们,而无需为库作者创建额外的工作。 集成非CocoaPods库,并使用简单...

    IOS安装CocoaPods详细教程

    一、简介 什么是CocoaPods ...2、使用CocoaPods可以很方便地查找新的第三方库,这些类库是比较“标准的”,而不是网上随便找到的,这样可以让我们找到真正好用的类库。 二、Cocoapods安装步骤 注意:在终

    CocoaPods1.9.0 安装使用教程详解

    2、使用CocoaPods可以很方便地查找新的第三方库,这些类库是比较“标准的”,而不是网上随便找到的,这样可以让我们找到真正好用的类库。 其实之前是没这么搞过ios的第三方类库 后来了解到通过CocoaPods工具可以为项

    详解2016 cocoapods的安装和使用以及版本升级遇到的问题

    开发iOS项目不可避免地要使用第三方开源库,CocoaPods的出现使得我们可以节省设置和更新第三方开源库的时间,在iOS开发中经常会用到第三方库如AFNetworking,ASIHttpRequest等,在使用第三方库时,你除了要导数源码外...

    精品Object-C语言教程文档项目资源,分享出来.zip

    本Demo利用Cocoapods管理第三方框架,若第一次使用本项目,请使用终端cd到如下图所示的文件夹,执行pod install命令即可。 Usage.png 1. pod repo update : 更新本地仓库 2. pod install : 下载新的库 如果你...

    高仿美团团购源码

    注:采用cocoapods管理第三方库,请双击meituan.xcworkspace启动工程。不要双击meituan.xcodeproj启动,否则会提示“library not found for -lPods-AFNetworking” 截图链接:...

    CocoaPods详解之----使用篇

    在进行iOS开发的时候,总免不了使用第三方的开源库,比如SBJson、AFNetworking、Reachability等等。使用这些库的时候通常需要:下载开源库的源代码并引入工程向工程中...CocoaPods是一个用来帮助我们管理第三方依赖库

    CocoaPods dependency manager:可可依赖经理-开源

    CocoaPods是Swift和Objective-C Cocoa项目的依赖项管理器。 它拥有超过8.2万个库,并在超过300万个应用程序中使用。... 最终目标是通过创建一个更加集中的生态系统来提高第三方开源库的可发现性和参与度。

    simplenote-macos:适用于macOS的Simplenote

    适用于iOS的使用管理第三方库。 由CocoaPods管理的第三方库和资源将通过上面的rake dependencies命令安装。 为什么不使用CocoaPods获取Sparkle 在撰写本文时,通过CocoaPods分发的Sparkle版本不支持沙盒功能,这是...

    常用的第三方库控件

    2、用CocoaPods加入一些常用、成熟的第三方库。 3、Vendors下放一些体量小,且自己可能会直接修改源码的第三方类。 4、实现一个从服务端获取内容到UI显示的过程,做成基类供不同业务继承使用。 5、实现一些常用的UI...

    CocoaPods dependency manager:可可依赖管理器-开源

    CocoaPods 是 Swift 和 Objective-C Cocoa 项目的依赖管理器。 它拥有超过 82,000 个库,并在超过 300 万个应用程序中使用。... 最终目标是通过创建一个更加集中的生态系统来提高第三方开源库的可发现性和参与度。

    驾校管理系统毕业设计源码-resume:恢复

    引入第三方库,能够使用第三方库提高开发效率 熟悉基本的算法和数据结构,以及C++ STL 的使用 实习经历 时间:2016-01-13 到 2016-07-19 公司:广州数锐智能公司 岗位:iOS开发实习生 工作内容:负责iOS客户端app的...

    最近在学习swift,发现网上资料都太老,很多不适用,所以自己慢慢摸索着学习,并记录一下,帮助想要学习swift的人

    最近有项目需要用到swift,自己又是新手,所以到处查,但是发现...这个项目用到了Cocoapods来管理第三方库,有不知道的同学可以网上自行查找,本人也是这样一点一点找来的,这个项目还在一步一步完善,陆续我会再跟新

Global site tag (gtag.js) - Google Analytics