LoginSignup
0
0

More than 5 years have passed since last update.

swift 中怎么安装使用Pod

Last updated at Posted at 2018-01-03

第一步,安装Pod
打开mac 的终端,如图Snip20180103_1.png
,然后在里面输入 sudo gem install cocoapods
这一行命令在您的系統上安裝CocoaPods gem 您可能會被提示輸入您的root密碼,然後按回車。請注意,密碼不會顯示在屏幕上,因為終端不顯示密碼。
再输入 pod setup 进行安装
第二步 使用CocoaPods运行Xcode项目

首先新建一个Xcode项目,关闭项目,打开终端,假如你把项目保存在了桌面Desktop
就输入cd ~/Desktop/CocoapodsTest , CocoapodsTest是你的项目名。换言之,也就是cd 后面跟的是你的项目路径,(Xcode工程文件上一级的目录文件夹)
要创建一个Podfile,在终端里输入 pod init 打开你的项目文件夹后,在里面会多几个文件,如图Snip20180103_3.png
打开Podfile
如下所示:
1| # Uncomment this line to define a global platform for your project |
2| # platform :ios, '9.0' |
3| |
4| target 'CocoapodsTest' do |
5| # Comment this line if you're not using Swift and don't want to use dynamic frameworks |
6| use_frameworks! |
7| |
8| # Pods for CocoapodsTest |
9| pod 'Firebase' |
10| end |

把第2行代码前面的#去掉,在第九行,加入一个 pod 'Firebase' ,'Firebase'是你需要的第三方库的名字
之后保存并关闭Podfile,打开终端,在里面输入 pod install。这样就把你需要的库导进去了。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0