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
相关推荐
similar71820 小时前
iOS pod install一直失败,访问github超时记录
ios·github
没头脑的ht1 天前
UITableView的复用原理
ios·swift
gp1031 天前
iOS主要知识点梳理回顾-2-多线程
ios·多线程·gcd
又菜又爱coding1 天前
iOS AES/CBC/CTR加解密以及AES-CMAC
ios
浏览器爱好者2 天前
如何使用Xcode进行iOS应用开发?
macos·ios·xcode
胖虎13 天前
iOS 自动翻滚广告条(榜单条)实现方案
ios·广告滚动·纵向轮播
KWMax3 天前
DeepSeek深度思考:客户端(Android/iOS)架构设计指南
android·ios·架构设计·deepseek
haomo20143 天前
苹果可折叠iPad:2028年的科技盛宴?
前端·科技·ios·ipad
ii_best3 天前
安卓/ios脚本开发按键精灵经验小分享
android·ios·个人开发
Sico2Sico3 天前
详解Swift中 Sendable AnyActor Actor GlobalActor MainActor Task、await、async
ios·swift6.0