iOS项目的依赖管理器 - CocoaPods

编辑于 2022-04-15 16:46:23 阅读 873

CocoaPodsSwiftObjective-C Cocoa项目的依赖管理器。类似 PHPcomposer, JavaMaven

安装

$ 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打开即可

参考

https://www.cocoapods.org

广而告之,我的新作品《语音助手》上架Google Play了,欢迎下载体验