美文网首页iOS开发指南
Cocoapods创建私有仓库

Cocoapods创建私有仓库

作者: 成长_路上 | 来源:发表于2018-04-09 16:26 被阅读0次

    一. 创建.podspec,强烈推荐第一种带demo

    pod lib create 名字
    pod lib create Test
    或
    pod spec create 名字
    pod spec create Test
    
    第一种创建.png 第一种创建目录结构说明.png

    二 .podspec文件相关说明

    Pod::Spec.new do |s|
    
    #""和‘’都可以
      # ―――  Spec Metadata  ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
    #名字
      s.name         = "Test"
    #版本
      s.version      = "0.0.1"
    #简介
      s.summary      = "测试测试"
    #描述
      s.description  = <<-DESC
    测试测试
                       DESC
    # 仓库主页
      s.homepage     = "https://coding.net/u/liyoucheng2014/p/JZYICommonUI"
    #截图
      # s.screenshots  = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
    #协议
    s.license          = { :type => 'MIT', :file => 'LICENSE' }
    #作者
      s.author             = { "史ios" => "542235666@qq.com" }
      # Or just: s.author    = "史ios"
      # s.authors            = { "史ios" => "542235666@qq.com" }
    #媒体
      # s.social_media_url   = "http://twitter.com/史ios"
    #平台
      # s.platform     = :ios
      # s.platform     = :ios, "5.0"
    
      #  When using multiple platforms
      s.ios.deployment_target = "8.0"
      # s.osx.deployment_target = "10.7"
      # s.watchos.deployment_target = "2.0"
      # s.tvos.deployment_target = "9.0"
    #资源地址
      s.source       = { :git => "https://git.coding.net/liyoucheng2014/JZYICommonUI.git", :tag => "#{s.version}" }
    #资源文件包括
      s.source_files = 'JZYICommonUI/Classes/**/*'
    #资源文件不包括
      #s.exclude_files = "JZYICommonUI/Classes/Exclude"
    #公开头文件
      s.public_header_files = "JZYICommonUI/Classes/**/*.h"
    #资源图片
      s.resources =  ['JZYICommonUI/Assets/*.png']
    
    # s.resource_bundles = {
    #   'JZYICommonUI' => ['JZYICommonUI/Assets/*.png']
    # }
    
      # s.preserve_paths = "FilesToSave", "MoreFilesToSave"
    
    #动态库
      # s.framework  = "SomeFramework"
      # s.frameworks = "SomeFramework", "AnotherFramework"
    #C文件
      # s.library   = "iconv"
      # s.libraries = "iconv", "xml2"
    
    #是否ARC
      # s.requires_arc = true
    
      # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
    #第三方依赖
      # s.dependency "JSONKit", "~> 1.4"
    
    end
    
    

    验证仓库

    pod lib lint 
    --verbose //显示详细信息 可选
    --allow-warnings //有警告 必须
    --use-libraries //使用了.frameworks/.libraries/.library/.framework 必须
    --sources='git@git.gigahome.cc:iOSPrivatePods/JZYPrivateSpecs.git,https://github.com/CocoaPods/Specs.git' 
    //使用了其它第三方私有仓库 必须
    
    

    三. github或者coding等上建立仓库并与本地管理仓库关联(只需要进行一次)

    3.1 建立私有仓库

    按住command+shift+.显示或者隐藏隐藏文件

    3.2 关联私有仓库

    pod repo add 私有仓库 远程仓库地址
    pod repo add Test https://git.coding.net/liyoucheng2014/JZYISpecs.git

    四. 建立内容仓库

    4.1 建立仓库

    图片.png

    四. 推送内容并打标签

    4.1 本地仓库关联远程仓库


    图片.png

    4.2 提交内容并打标签

    cd Test
    git remote add origin https://git.coding.net/liyoucheng2014/Test.git //关联远程仓库
    git add . //添加全部内容
    git commit -m "描述" //提交
    git push -u origin master -f //推送,
    git tag 0.1.0 //打标签
    git push origin --tags //推送标签
    

    //github上的版本里有readme文件和本地版本冲突所以加上-f,解决

    4.3 推送本地内容仓库

    pod repo push 私有仓库 内容
    pod repo push Test Test.podspec 
    --verbose //显示详细信息 可选
    --allow-warnings //有警告 必须
    --use-libraries //使用了.frameworks/.libraries/.library/.framework 必须
    --sources='git@git.gigahome.cc:iOSPrivatePods/JZYPrivateSpecs.git,https://github.com/CocoaPods/Specs.git' 
    //使用了其它第三方私有仓库 必须
    

    五、使用仓库

    5.1 pod search 库 (提示找不到)


    使用如下命令:

    rm ~/Library/Caches/CocoaPods/search_index.json
    

    5.2 删除仓库

    rm -rf ~/.cocoapods/repos
    

    六、生产ssh key

    ssh-keygen -t rsa -C 邮箱
    ssh-keygen -t rsa -C "542235666@qq.com"
    
    cat ~/.ssh/id_rsa.pub
    

    相关文章

      网友评论

        本文标题:Cocoapods创建私有仓库

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