swift用cocoaPods 打包静态库 (OC 与 Swift ,其实是一样的)

步骤、

1. 创建文件夹,用于承载项目

2. 打开终端,并且cd 到你的文件夹

3. 终端执行语句创建项目:

pod lib create 你的项目名
`等创建完成后,会自动打开项目。
在终端弹出

swift用cocoaPods 打包静态库 (OC 与 Swift ,其实是一样的)_第1张图片

4.设置打开项目中的: .podspec文件

# pod库名

s.name = 'PYHandlerDate_Swfit' 

# pod版本

s.version = '0.1.0'

# pod概述

 s.summary          = '时间管理工具'

# pod的详细描述,可选,也可以在前面加#号,注释掉

# s.description = <<-DESC

# # 在这里写pod的详细描述,注意 一定要比summary 的字段多
     时间的管理工具,时间的比较,时间的获取,object转换为Date类
# DESC

# pod的主页

s.homepage = 'https://github.com/MobDeveloper163/MyPodTest'

# 许可证书

s.license          = { :type => 'MIT', :file => 'LICENSE' }

# 作者 名字和邮箱地址

s.author           = { 'LiPengYue' => '[email protected]' }

# pod源代码在GitHub的仓库地址,以及pod版本

s.source           = { :git => 'https://github.com/LiPengYue/PYDateHandler_SwiftPOD.git', :tag => s.version.to_s }

# pod支持的最低版本

s.ios.deployment_target = '8.0'

# pod类库的源文件位置,这个要与你存放资源文件的路径一致

s.source_files = 'PYHandlerDate_Swfit/Classes/**/*'

# pod 关联的 其他的pod库
# s.dependency 'SDWebImage'
# s.dependency   "SDWebImage", "1.4.1"

5. 存放资源的路径

注意一定要与.podspec 中的 s.source_files 路径一致


swift用cocoaPods 打包静态库 (OC 与 Swift ,其实是一样的)_第2张图片
实力代码在这里写

swift用cocoaPods 打包静态库 (OC 与 Swift ,其实是一样的)_第3张图片
工具存放地点

6. 终端cd到Example

  1. pod install
  2. 检测.podspec配置是否正确
    cd ..终端执行,退回到上层目录
    pod lib lint 你的项目名.podspec
    根据提示修改你的错误

7.创建github库,并且与本地关联

  1. 在github中新建空仓库,并获取地址。
  2. cd到Example与的上层文件夹,将本地文件推送到github 仓库中
#创建本地git库
git init 

#添加到缓存
git add .

#commit到本地库
git commit -a -m "first commit"

#打tag,并且注意 一定要与.podspec中的tag一致
git tag "0.1.0"

#关联远程仓库
git remote add origin https://https://github.com/LiPengYue/PYDateHandler_SwiftPOD.git

#提交tag到远程库
git push origin master --tag

# 推送到远程分支 
git push 

# 如果刚建仓库,推送不成功 显示一下错误的话 用下面的代码
#push -f --set-upstream origin master error: failed to push some refs to #'https://github.com/LiPengYue/LateralTableViewCell.git'
#hint: Updates were rejected because the tip of your current branch is behind
#hint: its remote counterpart. Integrate the remote changes (e.g.
#hint: 'git pull ...') before pushing again.
#hint: See the 'Note about fast-forwards' in 'git push --help' for details.
git push -f --set-upstream origin master 

7.在cocoaPods注册,获取Token

pod trunk register 你的邮箱名字@163.com "用户名" --verbose # 邮箱 用户名

8.去邮箱查看并打开下面网址会出现这个界面

swift用cocoaPods 打包静态库 (OC 与 Swift ,其实是一样的)_第4张图片
邮箱中的内容

swift用cocoaPods 打包静态库 (OC 与 Swift ,其实是一样的)_第5张图片
打开网址后

9. 在终端中输入
注意你的终端cd到的是.podspec上级文件夹

 pod trunk push PYHandlerDate_Swfit.podspec --verbose

10.出现错误 ,如果提示这个,就直接加个 --allow-warnings

[!] The spec did not pass validation, due to 1 warning (but you can use --allow-warnings to ignore it).

 pod trunk push PYHandlerDate_Swfit.podspec --verbose

11. 好了,你可以去search 一下自己的工具了
找不到就
rm ~/Library/Caches/CocoaPods/search_index.json
pod update

其他命令

**1. 添加 其他用户 **
`pod trunk add-owner  你的库的名字 [email protected]`
问题:Authentication token is invalid or unverified. Either verify it with the email that was sent or register a new session.
需要`pod trunk register 已经加入的开发者邮箱@xxx.com 开发者名称`

12.问题集中营
[Cocoapods]项目添加Cocoapods支持遇到的坑
cocoaPods 打包静态库 遇到的坑 and git

参考文章:
感谢!感谢!还是感谢!
CocoaPods创建自己的Pod
Cocoapods使用----配置/安装/使用/完全卸载(一)
一步一步教你使用CocoaPods打包静态库

你可能感兴趣的:(swift用cocoaPods 打包静态库 (OC 与 Swift ,其实是一样的))