Author :JerryYang
Create by 2021.01.25
环境:
MacOS: 11.2
CocoaPods: 1.10.1
一、安装CocoaPods
- 安装需要⽤到Ruby,Mac⾃带了Ruby,我们把它更新到最新版本;
sudo gem update --system
- 更换源,现在用的源是 Ruby China。
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
# 查看当前源
gem sources -l
# 确保只有 gems.ruby-china.com
- 安装CocoaPods
sudo gem install cocoapods
# 如果提示:You don't have write permissions for the /usr/bin directory. 请执行下面的操作
sudo gem install cocoapods -n /usr/local/bin
- 安装CocoaPods
pod setup
二、CocoaPods简单使用
- 切换至项目根目录,新建 Podfile 文件;
- 打开Podfile 文件,配置需要的包,例如:
source '[https://github.com/CocoaPods/Specs.git](https://github.com/CocoaPods/Specs.git)'
platform :ios, '11.0'
target 'UnityFramework' do
pod 'UnityAds', '3.5.1'
end
- 执行安装
#如果是第一次过程可能比较漫长,请耐心等待
pod install
#如果需要更新,请执行
pod update
#要获取更多命令,请执行
pod help
-
安装完之后会生成一个新的工程文件,如下:
之后都用这个工程去开发
三、可能遇到的问题
如果pod setup 不顺利
采用:Git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master 该过程作用与 pod setup作用相同
1. FBAudienceNetwork下载不了的问题(开了VPN也下载不了)
切换至:/Users/feiyang/.cocoapods/repos/trunk/Specs
搜索:FBAudienceNetwork.podspec.json
修改 FBAudienceNetwork.podspec.json,(这里我填了我服务器的地址,只上传了6.2.1的版本)
"source": {
"http": "http://www.xrlmall.top/FBAudienceNetwork-6.2.1.zip",
"sha1": "31fd0c2be55af1862ec2803f7e69492c30d2b797"
},
