iOS项目的依赖管理器 - CocoaPods
 编辑于 2022-04-16 00:46:23 阅读 1935
CocoaPods是Swift和Objective-C Cocoa项目的依赖管理器。类似 PHP 的 composer, Java 的 Maven
安装
$ brew install cocoapods
或者
$ sudo gem install cocoapods
加速镜像
https://mirrors.tuna.tsinghua.edu.cn/help/CocoaPods/
cd ~/.cocoapods/repos
#可能不需要移除
pod repo remove master
#很慢,最终master目录3.2G
pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
使用
在项目根目录创建文件Podfile,类似
vi Podfile
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'ui-tableView' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  # Pods for ui-tableView
  pod "Masonry"
  pod "MJExtension"
end
target '2ui-tableViewDelegate' do
  use_frameworks!
  pod "MJExtension"
end
然后执行pod install,不出意外会创建一个项目名.xcworkspace文件,用Xcode打开即可
