cocopods 导入Github库步骤

1.打开终端,找到项目路径  cd 项目文件夹

2.pod search AFNetworking  查找第三方库

pod 'AFNetworking', '~> 3.0.4'

3.创建文件夹  touch Podfile   把    pod 'AFNetworking', '~> 3.0.4’复制进Podfile

4.pod install --no-repo-update


git.oschina

1.在oschina新建项目

克隆项目的时候要选中cd 到克隆的文件夹

2.添加 gitignore的时候也要在克隆的文件夹里面添加 gitignore(cd到项目文件夹)


****************************************************************************************************************************************************************************************************************************************************************************************************************

用CocoaPods管理项目中的第三方框架

打开你的项目所在的那个文件夹,新建一个叫Podfile的文件

bogon:~ liyilin$ cd /Users/liyilin/Desktop/cocoapodsTest

bogon:cocoapodsTest liyilin$ pod init

编辑Podfile文件

bogon:cocoapodsTest liyilin$ vim Podfile

终端显示Podfile内容如下

# Uncomment this line to define a global platform for your project# platform :ios, '9.0'target 'cocoapodsTest'do#Commentthis lineifyou're not using Swift and don'twanttousedynamic frameworks  use_frameworks!  # PodsforcocoapodsTestend~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~"Podfile"10L,257C

其中注释说如果使用Swift就得保留use_frameworks!

输入i进行编辑,终端显示如下,注意最后一行变为-- INSERT --,此时可以编辑

# Uncomment thislinetodefinea global platform for your project# platform :ios, '9.0'target'cocoapodsTest'do# Comment thislineifyou're not using Swift and don't want to use dynamic frameworksuse_frameworks!# Pods for cocoapodsTestend~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              -- INSERT --

然后我根据搜索出的AFNetworking的信息,编辑Podfile文件如下:

(去掉了platform前面的#,插入了pod 'AFNetworking', '~> 3.1.0')

# Uncomment thislinetodefinea global platform for your projectplatform :ios,'9.0'target'cocoapodsTest'do# Comment thislineifyou're not using Swift and don't want to use dynamic frameworksuse_frameworks!pod'AFNetworking','~> 3.1.0'# Pods for cocoapodsTestend~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              -- INSERT --

然后点击ESC,输入:wq保存并退出

# Uncomment this line to define a global platform for your projectplatform:ios,'9.0'target'cocoapodsTest'do# Comment this line if you're not using Swift and don't want to use dynamic frameworksuse_frameworks!pod'AFNetworking','~> 3.1.0'# Pods for cocoapodsTestend~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~                                                                              ~:wq

接下来为项目导入第三方库和相关依赖库

bogon:cocoapodsTest liyilin$ pod install

终端提示导入成功,并提示你从此使用cocoapodsTest.xcworkspace这个文件来编写项目

Analyzing dependenciesDownloading dependenciesInstalling AFNetworking (3.1.0)Generating Pods projectIntegrating client project[!] Please close any current Xcode sessionsandusecocoapodsTest.xcworkspacefor this projectfromnow on.Sending statsPod installation complete! Thereis1dependencyfromthe Podfileand1totalpod installed.

使用cocoapodsTest.xcworkspace打开项目,目录如下:

文/果啤(简书作者)

原文链接:http://www.jianshu.com/p/d5a9e4bee015

著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容