如何使用CocoaPods?
场景1:利用CocoaPods,在项目中导入第三方类库
主要命令行:

我们先创建这个神奇的PodFile。在终端中进入(cd命令)你项目所在目录(cd加一个空格在添加项目目录回车),然后在当前目录下,pod init回车,在输入open -a xcode podfile回车

这个时候会在你的选择的项目里面创建一个名为podfile的文件,并且会弹出它的文件


这个时候你需要做的就是把第一行,跟五到十八行的代码删掉,并把第二行的#删掉

到这个时候,你已经完成的一大半了。你现在要做的就是把你所需要的三方库pod进去就可以了,pod 'AFNetworking' 如下图所示:

添加完三方库之后,command+s保存,关掉podfile文件,回到终端上打pod install回车把你刚才添加的三方库安装到项目即可,然后就是等待终端安装三方库了,

当显示到现在的这个时候,恭喜你,你需要安装三方库已经安装成功了。现在你只需要把你的项目重新打开就可以使用了,是不是感觉很简单☺

现在我们来说下删除的:
我们点开项目pods->里面的Podfile,选择要删除的第三方,直接删掉,然后com + s保存一下,如图

第一步完成之后,我们打开终端,cd + 项目 (然后回车),输入 pod update --no-repo-update 命令行后在回车,等待终端运行完成,在重新打开运行一下把之前第三方留下的头文件删除就可以了,如图

如果还是不明白的可以问我哦Q:1255130032
网友评论