gitee上的 swift event库
https://gitee.com/lieami/EventSource
CocoaPods使用指南
什么是CocoaPods?
CocoaPods是iOS开发中最常用的依赖管理工具,可以帮助开发者方便地管理第三方库。
- Name
核心特点
- Type
- concept
- Description
- 中心化管理依赖
- 自动集成第三方库
- 版本管理
- 依赖解析
- Name
主要功能
- Type
- meaning
- Description
- 依赖管理
- 版本控制
- 库文件下载
- 工程配置
安装CocoaPods
// 安装Ruby(Mac自带)
ruby -v
// 安装CocoaPods
sudo gem install cocoapods
// 设置镜像源(可选)
gem sources --add https://gems.ruby-china.com/
gem sources --remove https://rubygems.org/
基本使用
掌握CocoaPods的基本命令可以帮助你更好地管理项目依赖。
- Name
常用操作
- Type
- steps
- Description
- 创建Podfile
- 添加依赖库
- 安装依赖
- 更新依赖
- Name
使用技巧
- Type
- notes
- Description
- 指定版本号
- 使用本地库
- 多target配置
- 定期更新
常用命令
// 项目初始化
pod init
// 安装依赖
pod install
pod update
// 搜索库
pod search 库名
// 查看版本
pod --version
Podfile配置
Podfile是CocoaPods的核心配置文件,用于声明项目依赖。
- Name
配置项
- Type
- rules
- Description
- 平台版本
- 依赖库
- 版本号
- 源地址
- Name
最佳实践
- Type
- key-points
- Description
- 明确版本号
- 使用官方源
- 及时更新
- 避免冲突
Podfile示例
// Podfile基本结构
platform :ios, '13.0'
target 'MyApp' do
pod 'Alamofire', '~> 5.0'
pod 'SwiftyJSON', '~> 4.0'
pod 'SDWebImage'
pod 'SnapKit'
end
三钱法Podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '16.0'
target 'Sanqianfa' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for Sanqianfa
pod 'Moya','~> 15.0'# 网络底层
pod 'Moya/Combine', '~> 15.0'# 网络底层结合SwiftUICombine
pod 'KakaJSON'# JSON处理
pod 'SwiftyJSON'# JSON处理
pod 'SwifterSwift'
end