美文网首页swift
swift用cocoaPods 打包静态库 (OC 与 Swi

swift用cocoaPods 打包静态库 (OC 与 Swi

作者: LiYaoPeng | 来源:发表于2017-12-17 21:22 被阅读65次

    步骤、

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

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

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

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

    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' => '702029772@qq.com' }
    
    # 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/**/*'
    

    5. 存放资源的路径

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


    实力代码在这里写
    工具存放地点

    6. 终端cd到Example

    1. pod install
    2. 检测.podspec配置是否正确
      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 --tags
    

    7.在cocoaPods注册,获取Token

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

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

    邮箱中的内容
    打开网址后

    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

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

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

    相关文章

      网友评论

        本文标题:swift用cocoaPods 打包静态库 (OC 与 Swi

        本文链接:https://www.haomeiwen.com/subject/repdwxtx.html