cocoapods 使用 二、实战代码篇章

来源:互联网 发布:mac设置iphone铃声2017 编辑:程序博客网 时间:2024/05/01 08:36

上一节中讲了如何安装 cocoapods,本章主要介绍,项目中如何使用,引入

1、新建一个项目xcode项目,我这次新建的项目名称是CocoapodsTest (名字随意,根据自己项目需要)

2,打开项目所在路径,使用命令行,打开项目文件所在路径


    打开所在路径,进入**.xcodeproj 所在目录下,创建Podfile文件

输入如下内容

platform :ios,'7.0'pod 'AFNetworking','~>2.0'
保存,退出,回到**.xcodeproj 所在目录,然后执行

pod install
出现如下结果:

lenove-pc:CocoapodsTest juanq$ pod installUpdating local specs repositoriesAnalyzing dependenciesDownloading dependencies        Installing AFNetworking (2.6.1)Generating Pods projectIntegrating client project[!] Please close any current Xcode sessions and use `CocoapodsTest.xcworkspace` for this project from now on.Sending statsPod installation complete! There is 1 dependency from the Podfile and 1 totalpod installed.

这一步算是完成,根据上面提示Please close any current Xcode sessions and use `CocoapodsTest.xcworkspace` for this project from now on.

此后打开项目,请不要再像以前使用CocoapodsTest.xcodeproj打开项目,而是通过点击CocoapodsTest.xcworkspace打开项目

然后出现下面界面了,



3 ,到了上面这一步还不是真正完事,还要进行下面这一步,因为我们在项目中import对应的库没有反应

   即这个问题CocoaPods中的头文件import导入时不能自动补齐的解决方法

我参考了下面文章:http://www.360doc.com/content/15/0302/15/20919452_451991897.shtm

键入 $(PODS_ROOT)  

,右侧会弹出 两个选项 选择 recursive,这样就能在我们的目录下搜索到我们想要的文件


然后项目中直接 import afnetworing了,如下


至此,算是完成了。哈哈,休息一下。



0 0
原创粉丝点击