美文网首页
制作自己的Pod库

制作自己的Pod库

作者: 我是不是叫没烦恼 | 来源:发表于2017-05-23 14:19 被阅读25次
    1. 首先在github新建repo


      github.png
    2. clone仓库至本地


      clone.png
    3. 初始化项目


      initial.png
    4. 创建podspec文件

    pod spec create MBMediator https://github.com/MarioBiuuuu/MBMediator.git
    
    podspec.png
    1. 配置podspec
    Pod::Spec.new do |s|
      s.name         = "MBMediator"
      s.version      = "0.0.1"
      s.summary      = ""
      s.description  = <<-DESC
                       DESC
      s.homepage     = "https://github.com/MarioBiuuuu/MBMediator"
      s.license      = "MIT"
      s.author             = { "AuthorName" => "AuthorEmail" }
      s.platform     = :ios, "7.0"
      s.source       = { :git => "https://github.com/MarioBiuuuu/MBMediator.git", :tag => s.version}
      s.source_files  = "MBMediator", "MBMediator/**/*.{h,m}"
    end
    

    s.source_files = ' ' 的多种写法

    ss.source_files = 'MBMediator/Class/*.{h,m}'
    

    表示MBMediator/Class/目录下的所有 .h 和 .m 文件

    s.source_files = 'MBMediator/**/ .'
    

    /后面的 . 应是 星号,MarkDowm语法冲突在此不能正常显示
    表示MBMediator/ 目录下所有文件,包括子目录下所有文件。 **/.表示递归
    当有多个文件时,应用,隔开

     s.source_files = 'MBMediator/Class.{h,m}', 'MBMediator/Util*'
    
    1. 给项目打tag,并push到远程仓库
    git tag 0.0.1
    

    push到远程仓库

    git push origin --tags
    
    1. 验证podspec是否正确
    pod lib lint
    
    liblint.png
    1. pod Trunk注册
     pod trunk register email地址 'MBMediator'
    
    trunk.png

    根据提示前往邮箱确认,然后执行

    pod trunk me
    
    trunkme.png
    1. 上传MBMediator.podspec 到 CocoaPods/repo
    pod trunk push MBMediator.podspec
    
    result.png
    1. 检验
    pod search MBMediator
    
    1. 上传成功后搜索不到自己的库怎么办?
    [!] Unable to find a pod with name, author, summary, or descriptionmatching '······'
    

    删除~/Library/Caches/CocoaPods目录下的search_index.json文件
    由于pod setup成功后会生成~/Library/Caches/CocoaPods/search_index.json文件。
    终端输入rm ~/Library/Caches/CocoaPods/search_index.json
    删除成功后再执行pod search

    相关文章

      网友评论

          本文标题:制作自己的Pod库

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