iOS_制作 cocopods库

文章目录


1.创建项目

在 github 上创建仓库,克隆到本地:

bash 复制代码
git clone https://github.com/mxh-mo/MOOXXX.git

在项目目录下执行:

bash 复制代码
pod lib create <库名称>

进行一些配置的选择:

bash 复制代码
# 希望在那个平台上使用
What platform do you want to use?? [ iOS / macOS ]
 > iOS

# 希望使用什么语言
What language do you want to use?? [ Swift / ObjC ]
 > Swift

# 是否包含 demo 工程在你的库里
Would you like to include a demo application with your library? [ Yes / No ]
 > Yes

# 需要使用哪个测试框架
Which testing frameworks will you use? [ Quick / None ]
 > None

# 需要包含 UI 测试么
Would you like to do view based testing? [ Yes / No ]
 > No

2.配置项目

打开 <项目名>.podspec 文件,对项目进行配置:

bash 复制代码
Pod::Spec.new do |s|
  s.name             = '<库名>'
  s.version          = '<库版本>'
  s.summary          = '<简短描述>'
  s.description      = <<-DESC
<详细描述。。。。。。。。。。。。。。。。。。。。。。。。>
                       DESC
  s.homepage         = '<主页地址>'
  s.screenshots     = '<截图地址1>', '<截图地址2>'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }  # 证书
  s.author           = { 'momo' => '123456@qq.com' } # 作者信息
  s.source           = { :git => '<远程仓库地址>', :tag => s.version.to_s }
  s.social_media_url = '<社交平台地址>'
  s.ios.deployment_target = '10.0' # iOS系统支持的最低版本
  s.source_files = 'MOODemo/Classes/**/*' # 资源文件目录
  s.resource_bundles = { # bundle 打包的资源文件
    'MOODemo' => ['MOODemo/Assets/*.png']
  }
  s.public_header_files = 'Pod/Classes/**/*.h' # 公开的头文件
  s.frameworks = 'UIKit', 'MapKit' # 使用到的系统库
  s.libraries = 'c++', 'bz2', 'iconv', 'z.1.2.8' # 依赖的系统静态库
  s.dependency 'AFNetworking', '~> 2.3' # 依赖的第三方库
end

修改完成后进行验证:

bash 复制代码
pod lib lint --allow-warnings 	# 验证本地库
pod spec lint --allow-warnings	# 验证远端

Tips: --allow-warnings 这个指令用来忽略警告


3.发布

注册账户:

bash 复制代码
pod trunk register <邮箱> '<你的名称>'

打开邮箱验证

bash 复制代码
# 发布公有库
pod trunk push <项目名>.podspec
# 发布私有库
pod repo push <仓库地址> <项目名>.podspec
相关推荐
游戏开发爱好者81 小时前
日常开发与测试的 App 测试方法、查看设备状态、实时日志、应用数据
android·ios·小程序·https·uni-app·iphone·webview
黑码哥1 小时前
ViewHolder设计模式深度剖析:iOS开发者掌握Android列表性能优化的实战指南
android·ios·性能优化·跨平台开发·viewholder
2501_915106323 小时前
app 上架过程,安装包准备、证书与描述文件管理、安装测试、上传
android·ios·小程序·https·uni-app·iphone·webview
2501_915106323 小时前
使用 Sniffmaster TCP 抓包和 Wireshark 网络分析
网络协议·tcp/ip·ios·小程序·uni-app·wireshark·iphone
熊猫钓鱼>_>3 小时前
移动端开发技术选型报告:三足鼎立时代的开发者指南(2026年2月)
android·人工智能·ios·app·鸿蒙·cpu·移动端
徐同保1 天前
通过ip访问nginx的服务时,被第一个server重定向了,通过设置default_server解决这个问题
ios·iphone
2501_915918411 天前
在 iOS 环境下查看 App 详细信息与文件目录
android·ios·小程序·https·uni-app·iphone·webview
2501_916007471 天前
没有 Mac 用户如何上架 App Store,IPA生成、证书与描述文件管理、跨平台上传
android·macos·ios·小程序·uni-app·iphone·webview
夏幻灵2 天前
HTTPS全面解析:原理、加密机制与证书体
ios·iphone
TheNextByte12 天前
如何在iPhone上恢复已删除的笔记的综合指南
笔记·ios·iphone