• 制作自己的Pod库(公有/私有)


    https://www.jianshu.com/p/ece0b5721461

    2018.04.12 16:43* 字数 1168 阅读 244评论 0

    目的:1.管理自己常用的类;2.组件化开发

    步骤:

    1.想一个比较酷的名字,在桌面简历文件夹。

    2.打开terminal,cd到这个文件夹下面,执行pod lib create  xxx(这里我们以JJCategoryKit为例子,下同)命令,如下图。这个过程会问几个问题,根据实际情况输入回答即可。这里我们选择添加demo,结束的时候会自动Lanuch这个app.

    localhost:JJCategoryKit Jason$ pod lib create JJCategoryKit

     

    3.将你需要制作的库文件,添加到Classes文件夹中,如下图所以。

     

    4.修改JJCategoryKit.podspec索引。主要是修改s.homepage,s.source ,s.source_files,s.public_header_files。其中s.dependency为我们所依赖的第三库。其他诸如s.version ,s.summary等根据时间情况修改。

    5.cd到Example下面运行pod install --no-repo-update 命令。这是点击workspce打开工程就可以看到我们添加的文件已经可以在工程里面了。

    6. cd 到Example 上一层,(如果是在Example下可以cd ..)用pod lib lint 检测podspec是否正确。通常情况下是没有问题的,如果有错误根据提示修改就可以了,都是基本错误。

    localhost:JJCategoryKit Jason$ pod lib lint

     ->JJCategoryKit (0.1.0)

        - ERROR | [iOS] file patterns: The `public_header_files` pattern did not match any file.

    如这个错误就是s.public_header_files 要从'Pod/Classes/**/*.h' 改为'JJCategoryKit/Classes/**/*.h'。

     

    看到这里也许有人发现第4步中的s.homepage,s.source 地址我们没有,这里说明。这个只需要我们在github或者oschina新建repositories 仓库即可。Repository name最好和你的库名称保持一致。 s.source就是对应的仓库地址,s.homepage对应主页,我们可以找一个好的页面或则直接就是你的GitHub主页也可以。

     

    7.到这里本地的工作差不多已经做完了,接下来就是将我们的工程push到s.source对应的github仓库了。

    依次执行:

    localhost:JJCategoryKit Jason$ cd /Users/Jason/Desktop/JJCategoryKit/JJCategoryKit 

    localhost:JJCategoryKit Jason$ git remote add origin https://github.com/anhuijhy/JJCategoryKit.git

    localhost:JJCategoryKit Jason$ git add .

    localhost:JJCategoryKit Jason$ git commit -a -m "0.1.0"

    localhost:JJCategoryKit Jason$ git pull origin master

    localhost:JJCategoryKit Jason$ git push origin master

    localhost:JJCategoryKit Jason$ git tag 0.1.0

    localhost:JJCategoryKit Jason$ git push origin 0.1.0

    不出意外我们异步到github就可以看到我们的push了。而且包含了sepc中的相关信息,但是如果我们pod的话却发现没有找到我们pod库,那是因为公用的pod是要把spec上传到cocospod官方的。接着往下看........

     

    8.将spec索引上传到官方需要先注册,命令如下

    pod trunk register 电子邮箱 '您的姓名' --description='macbook pro'

    注意邮箱必须正确,收到邮件后需要点击连接确认激活。

     

    9.激活后江spec push到官方,这个过程可能需要一点时间,请耐心等等待。

    localhost:JJCategoryKit Jason$ pod trunk push JJCategoryKit.podspec

     

    等待之后就是✌️,如下图。

     

    此时,在去github看的话,一些管pod的说明,也自动变好了。pod库终于可以使用了。


    如果需要修改,执行下面的命令以提交更新..

    git commit -m "1.0.0" (先提交当前修改)

    git tag 1.0.1 (添加tag)

    git push --tags (推送tag到远程)

    git push origin master (推送到远程到代码仓库)

    pod trunk push JJCategoryKit.podspec


    10.如果pod 是私有,比如组件化开发,就不需要发布到官方,可以自己在github创建spec索引(也就是新建一个Repository),然后关联

    a.pod repo可以查看本地索引库。

    b.pod repo add <本地索引库的名字>  <远程索引库的地址> ,创建本地索引库并和远程索引库做关联(注:本地索引库的名字建议和远程索引库起的名字一样)。

    c.cd 到本地索引库前面,pod spec lint - -verbose - -allow-warnings 检测索引库。

    c.pod repo push <本地索引库> <索引文件名> - -verbose - -allow-warnings,提交到远程索引库。

    d.pod需要使用的时候需要添加source '私有库地址' 到podfile文件。

    11.错误解决:

    a.如果trunk push 出现 error: include of non-modular header inside framework module ··· [-Werror,-Wnon-modular-include-in-framework-module] 可以 加上--use-libraries解决。

    b.如果出现waring 可以加入 --allow-warnings

  • 相关阅读:
    Dubbo
    支持微服务架构落地的Java框架
    thinkphp6的主要特性
    thinkphp5的主要特性
    RPC
    HTTP1.0 HTTP1.1 HTTP2.0 主要特性对比
    RabbitMQ 生产环境配置详解
    分布式AKF拆分原则
    通过Hystrix了解分布式接口级的高可用
    Python中使用grpc与consul
  • 原文地址:https://www.cnblogs.com/sundaysgarden/p/10748789.html
Copyright © 2020-2023  润新知