美文网首页
Cocoapods发布

Cocoapods发布

作者: Mominglaile | 来源:发表于2017-03-20 21:20 被阅读11次

    Cocoapods发布

    • 注册
    $ pod trunk register xxxxxxxx@qq.com "name"
    

    注册成功会出现以下提示

    [!] Please verify the session by clicking the link in the verification email that has been sent to 281090013@qq.com
    
    • 查询 pod注册信息
    $ pod trunk me
    

    成功会打印以下信息

      - Name:     XXXXX
      - Email:    XXXXXXXX@qq.com
      - Since:    September 23rd, 09:54
      - Pods:     None
      - Sessions:
        - September 23rd, 09:54 - January 29th, 2017 10:02. IP:
        XXX.XX.XXX.XXX
    
    • 到了这步,随便讲下在github上面创建一个测试的 repository

    详情图如下:


    798533EB-01B2-46A4-A759-3A5687F00A00.png

    会用的忽略吧.....

    • 下一步....


      2.png

    拿到新仓库的链接,开始到 SourceTree 发挥了

    3.png

    把仓库克隆下来

    4.png
    • 下一步创建项目并写好你要上传的pod文件,我这里随便找了一个 Categorys 来测试,用到谁的,纯属巧合,你可以怪我咯...

    不废话,Xcode的就自己琢磨
    以下是做好之后的项目结构:

    5.png 6.png 7.png
    • 好,到来重要环节

    拿到这张图所在的指那个你刚刚创建仓库的链接

    8.png
    • 首先
      1.在终端cd进项目根目录
        $ cd /Users/name/Documents/XXXXTest 
    

    2.接着

    $ pod spec create https://github.com/liuconglaile/XXXXTest
    

    这一串 https://github.com/liuconglaile/XXXXTest 就是刚刚那张图片复制的地址

    假如你输入命令后出现以下内容:

    ――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
    
    I’ve recently added [XXXXTest](https://github.com/CocoaPods/Specs/tree/master/XXXXTest) to the [CocoaPods](https://github.com/CocoaPods/CocoaPods) package manager repo.
    
    CocoaPods is a tool for managing dependencies for OSX and iOS Xcode projects and provides a central repository for iOS/OSX libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.
    
    However, XXXXTest doesn't have any version tags. I’ve added the current HEAD as version 0.0.1, but a version tag will make dependency resolution much easier.
    
    [Semantic version](http://semver.org) tags (instead of plain commit hashes/revisions) allow for [resolution of cross-dependencies](https://github.com/CocoaPods/Specs/wiki/Cross-dependencies-resolution-example).
    
    In case you didn’t know this yet; you can tag the current HEAD as, for instance, version 1.0.0, like so:
    
    
    
    $ git tag -a 1.0.0 -m "Tag release 1.0.0"
    $ git push --tags
    
    
    
    ――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
    
    [!] This repo does not appear to have semantic version tags.
    
    After commiting the specification, consider opening a ticket with the template displayed above:
      - link:  https://github.com/liuconglaile/XXXXTest/issues/new
      - title: Please add semantic version tags
    
    Specification created at XXXXTest.podspec
    
    • 恭喜,成功一半了!

    它提示你, XXXXTest.podspec 文件要修改

    但是里面有一堆有的没的,全是英文,很多东西是可以不要的,我自己精简过后:

    Pod::Spec.new do |s|
    
      s.name         = "XXXXTest"
      s.version      = "0.0.1"
      s.summary      = "这是我测试pod的一个分类,仅供娱乐..."
      s.homepage     = "https://github.com/liuconglaile/XXXXTest"
      s.license      = "MIT"
      s.authors      = { "liuconglaile" => "momingcode@icloud.com" }
      s.platform     = :ios, "7.1"
      s.source       = { :git => "https://github.com/liuconglaile/XXXXTest.git", :tag => s.version }
    
      s.source_files  = "Categorys", "Categorys/*.{h,m}"
    
    
    end
    
    • s.name 是库的名称
    • s.version 是库原代码版本号
    • s.summary 是对库的一个简单的介绍
    • s.homepage 声明库的主页
    • s.license 是所采用的授权版本
    • s.author 是库的作者。
    • s.platform 是库所支持的软件平台,这在我们最后提交进行编译时有用。
    • s.source 声明原代码的地址。(我这里是托管在github上,所以这里将地址copy过来就行了)

    正常在发布的时候都会打上一个tag,如版本0.0.1就会打上一个名为0.0.1的tag,
    你也可以选择一个最新的commit来作为该库0.0.1版的代码, 比如它本身生成的样子(有时间最好看看里面长啥样的,别急着删)

    用的是tag的话,就像我上面写的那样.每次有新版本,就改改 s.version就好

    • s.source_files 声明了库的源代码的位置,这个地方不能填错了。

    s.source_files = "Categorys", "Categorys/*.{h,m}"

    我这里 Categorys 就是文件夹名&pod名
    Categorys/ 这个呢,就是代表着

    项目根目录/文件夹/*.{h,m} ----- *.{h,m}代表着改文件夹里面所有的.h.m文件
    • 验证spec文件
    $ pod spec lint
    
    

    或者

    $ pod spec lint --verbose
    
    

    打印:

    9.png
    • 推送
    $ pod trunk push
    

    漫长的等待.....这里可以考研一下自己的人品

    10.png

    嗯,然后就再也没有然后了,接下来的自己琢磨吧

    另外

    CocoaPods 1.1.0.beta.1 is available.
    To update use: `sudo gem install cocoapods --pre`
    [!] This is a test version we'd love you to try.
    

    这句话,别不记得看,不然你下次百度就不好意思了....

    相关文章

      网友评论

          本文标题:Cocoapods发布

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