菜鸟 Cocoapods

初学者 Cocoapods

1.cocapods 安装命令

(1)ruby -v 和 gem -v 查看ruby的版本号

(2)在终端输入  gem install cocoapods 命令 终端将出现以下文字

 

CHANGELOG:

## 0.26.2

[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.26.1...0.26.2)

• [cocoapods-core](https://github.com/CocoaPods/Core/compare/0.26.1...0.26.2)

• [Xcodeproj](https://github.com/CocoaPods/Xcodeproj/compare/0.11.1...0.13.0)

###### Bug Fixes

* Fixed a crash which was causing a failure in `pod lib create` if the name of

  the Pod included spaces. As spaces are not supported now this is gracefully

  handled with an informative message.  

  [Kyle Fuller](https://github.com/kylef)

  [#1456](https://github.com/CocoaPods/CocoaPods/issues/1456)

* If an user target doesn't specify an architecture the value specified for the

  project is used in CocoaPods targets.  

  [Fabio Pelosin](https://github.com/irrationalfab)

  [#1450](https://github.com/CocoaPods/CocoaPods/issues/1450

* The Pods project now properly configures ARC on all build configurations.  

  [Fabio Pelosin](https://github.com/irrationalfab)

  [#1454](https://github.com/CocoaPods/CocoaPods/issues/1454)

 

Successfully installed cocoapods-0.26.2

Parsing documentation for cocoapods-0.26.2

Done installing documentation for cocoapods after 6 seconds

1 gem installed

(2)出现红色字体相似的内容 在输入命令 pod setup  

终端将出现以下文字

 

Setting up CocoaPods master repo

Already up-to-date.

Setup completed (push access)

 

(3) 接下来用 cd  命令  进入你要增加 pods 的项目文件夹中 (例:cd/Desktop/Headlines  这是进入我桌面的Headlines文件夹密令) 

(4)现在在你的项目文件中创建Podfile文件

密令输入依次如下:

 touch Podfile

 open -e Podfile

密令输入完后 将会打开Podfile文件的编辑 然后在文件中加入如下内容:

platform :ios

pod 将依赖的库名 (例:pod 'JSONKit')(ps:可以在终端输入命令 pod search json 搜索相关json的库)

(5)然后保存文件 Podfile 

在终端输入命令 pod install   

运行完后 进入你的项目文件夹就可以看到想要的东西啦。要打开工程的话 必须 打开.xcworkspace 文件 而不是.xcodeproj