Xcode框架Cocopods 支持Objective-C和Swift的第三方库管理工具。官方地址:https://cocoapods.org【pod命令】常用命令pod init 在项目目录里创建Podfilepod install 按Podfile配置安装创建新的项目文件.xcworkspacepod update 按Podfile配置更新框架pod search查找某个框架。然后将返回信息的pod开头的行复制到Podfile文件中完成配置辅助参数--verbose 显示详细信息(建议使用,因为有时候要等很久却不知道处理情况)--help 获得帮助--no-repo-update 放在install和update命令后,跳过repo更新。【安装cocoapods】$ sudo gem install cocoapods如果出现不能连接到 https://rubygems.org/ 错误,说明需要挂VPN安装。国内也临时改为 http://ruby.taobao.org 服务器安装,步骤如下:$ gem sources --remove https://rubygems.org/ /*移除rubygems.org安装源*/https://rubygems.org/ removed from sources$ gem sources -a http://ruby.taobao.org/ /*添加taobao为gem安装源*/$ gem sources -l /*显示当前安装源*/*** CURRENT SOURCES ***http://ruby.taobao.org/$ sudo gem update --system /*更新gem库,可跳过这步*/......RubyGems system software updated$ sudo gem install cocoapods -V /*安装cocoapods并查看安装详细信息,需要等待一会儿*/$ gem sources --remove http://ruby.taobao.org/ /* 改回gem源 */$ gem sources -a https://rubygems.org/【常用框架】$ pod list /* 可获得全部框架列表 */CocoaLumberjack 强大的日志框架。性能优于NSLog,另外还可配合XcodeColors插件彩色显示调试输出信息。AFNetworking 常用的网络框架。FMDB 方便SQLite数据库操作的框架。【例子】假设当前项目是Demo,安装CocoaLumberjack框架后,再添加AFNetowrking框架,并更新。$ cd ~/Developer/Demo/$ lsDemo Demo.xcodeproj DemoTests$ pod init$ lsDemo Demo.xcodeproj DemoTests Podfile$ pod search CocoaLumberjack --verbose…-> CocoaLumberjack (2.0.1) A fast & simple, yet powerful & flexible logging framework for Mac and iOS. pod 'CocoaLumberjack', '~> 2.0.1' - Homepage: https://github.com/CocoaLumberjack/CocoaLumberjack - Source: https://github.com/CocoaLumberjack/CocoaLumberjack.git - Versions: 2.0.1, 2.0.0, 2.0.0-rc2, 2.0.0-rc, 2.0.0-beta4, 2.0.0-beta3, 2.0.0-beta2, 2.0.0-beta, 1.9.2, 1.9.1, 1.9.0, 1.8.1, 1.8.0, 1.7.0, 1.6.5.1, 1.6.5, 1.6.4, 1.6.3, 1.6.2, 1.6.1, 1.6, 1.3.3, 1.3.2, 1.3.1, 1.3, 1.2.3, 1.2.2, 1.2.1, 1.2, 1.1, 1.0 [master repo] - Subspecs: - CocoaLumberjack/Default (2.0.1) - CocoaLumberjack/Core (2.0.1) - CocoaLumberjack/Extensions (2.0.1) - CocoaLumberjack/CLI (2.0.1)…/* 复制框架信息中pod开头的那行:『pod 'CocoaLumberjack', '~> 2.0.1’』 */$ nano Podfile /* 用文本编辑器,粘贴到Podfile文件中 ’/$ cat Podfile /* 结果如下 */# Uncomment this line to define a global platform for your project# platform :ios, '6.0'target 'Demo' dopod 'CocoaLumberjack', '~> 2.0.1'endtarget 'DemoTests' doend$ pod install --verbose /* 开始安装并显示详细的安装信息 */ PreparingUpdating local specs repositoriesUpdating spec repo `master`…Integrating client project[!] Please close any current Xcode sessions and use `Demo.xcworkspace` for this project from now on.…/* 看见[!]那行话,就表示安装成功了,关闭Xcode项目,用.xcworkspace打开就可以了 */$ open Demo.xcworkspace /* Xcode会打开.xcworkspace */$ pod search AFNetworking-> AFNetworking (2.5.4) A delightful iOS and OS X networking framework. pod 'AFNetworking', '~> 2.5.4'…/* 复制 pod 开头那行,用文本编辑器编辑Podfile,粘贴进去 */$ nano Podfile$ pod update --no-repo-updateUpdate all podsAnalyzing dependenciesDownloading dependenciesInstalling AFNetworking (2.5.4)Using CocoaLumberjack (2.0.1)Generating Pods projectIntegrating client projectSending stats$/* 跳过repo本地库更新,更新所有框架完成 */