cocoapods使用

2019-01-24  本文已影响0人  好大一棵树6

1、cd到iOS工程目录

2、执行pod init
会自动生成如下文件

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'FacebookLogin' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for FacebookLogin
end

3、编辑Podfile添加需要添加的第三方库

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'FacebookLogin' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for FacebookLogin

  pod 'FBSDKLoginKit'
end

然后执行

pod install

执行完成后,会自动生成文件

4、打开文件FacebookLogin.xcworkspace

5、cocoapods安装
https://guides.cocoapods.org/using/getting-started.html

6、常用命令
6.1、搜索

pod search FBSDKLoginKit

6.2、更新库

pod update
或者
pod install --verbose --no-repo-update
pod update --verbose --no-repo-update

7、出现比较慢的情况
查看镜像

gem source -l

删除原来的镜像

$ gem sources --remove https://rubygems.org/

使用

gem sources -a https://gems.ruby-china.com/

8、clone Specs的方法;
参考:
https://www.jianshu.com/p/852e76f78a7b

cd ~/.cocoapods/repos 
pod repo remove master

git clone https://git.coding.net/CocoaPods/Specs.git

然后把Specs目录改名为master即可

9、查看工程中第三方库的版本
Podfile.lock 记录了所有当前使用的第三方库的版本

上一篇下一篇

猜你喜欢

热点阅读