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
相关推荐
笑尘pyrotechnic5 小时前
LLDB进阶:使用命令行进行检查
ios·objective-c·cocoa·lldb
z***y8627 小时前
Swift在iOS中的Xcode
ios·xcode·swift
AirDroid_cn7 小时前
iOS 18 后台应用偷跑流量,如何限制?
macos·ios·cocoa
Q688238868 小时前
Comsol仿真金属纳米颗粒超表面的多极分解之旅
xcode
明君8799710 小时前
Flutter 图纸标注功能的实现:踩坑与架构设计
android·ios
江东小bug王11 小时前
深入理解 UINavigationController:生命周期、动画优化与性能调优
ios
Lexiaoyao2012 小时前
Apple StoreKit 2 开发指南
ios·apple
2501_915106321 天前
iOS App 测试工具全景分析,构建从开发调试到线上监控的多阶段工具链体系
android·测试工具·ios·小程序·uni-app·iphone·webview
Digitally1 天前
如何通过蓝牙将联系人从 iPhone 传输到 Android
android·ios·iphone
90后的晨仔1 天前
2025年11月27日年解决隐私清单导致审核总是提示二进制无效的问题
ios