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' => '[email protected]' } # 作者信息
  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
相关推荐
Unlimitedz34 分钟前
iOS音视频解封装分析
ios·音视频
lichao8904272 小时前
谈谈未来iOS越狱或巨魔是否会消失
ios
fzxwl6 小时前
隆重推荐(Android 和 iOS)UI 自动化工具—Maestro
android·ui·ios
运维-大白同学18 小时前
go-中间件的使用
中间件·golang·xcode
若水无华2 天前
fiddler 配置ios手机代理调试
ios·智能手机·fiddler
Aress"2 天前
【ios越狱包安装失败?uniapp导出ipa文件如何安装到苹果手机】苹果IOS直接安装IPA文件
ios·uni-app·ipa安装
Jouzzy3 天前
【iOS安全】Dopamine越狱 iPhone X iOS 16.6 (20G75) | 解决Jailbreak failed with error
安全·ios·iphone
瓜子三百克3 天前
采用sherpa-onnx 实现 ios语音唤起的调研
macos·ios·cocoa
左钦杨3 天前
IOS CSS3 right transformX 动画卡顿 回弹
前端·ios·css3
努力成为包租婆3 天前
SDK does not contain ‘libarclite‘ at the path
ios