cocoapods 使用 二、实战代码篇章

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

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

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


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

输入如下内容

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

pod install
出现如下结果:

lenove-pc:CocoapodsTest juanq$ pod install
Updating local specs repositories
Analyzing dependencies
Downloading dependencies
        Installing AFNetworking (2.6.1)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `CocoapodsTest.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total
pod installed.

这一步算是完成,根据上面提示Please close any c urrent 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
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值