美文网首页
Pod本地组件传到Github

Pod本地组件传到Github

作者: 武汉刘德华 | 来源:发表于2022-10-26 16:15 被阅读0次

    1.首先配置SAuthentication Keys (多个Keys需要注意不要覆盖了)

    这个就不多说了,在我之前文章有过具体怎么配置(https://www.jianshu.com/p/691fd56f1be5

    Authentication Keys

    2.Github中创建新的Repository。

    这个就不多说了,在我之前文章有过具体怎么创建(https://www.jianshu.com/p/691fd56f1be5

    远程仓库

    3.注册CocoaPods账户

    1)注册:

    pod trunk register mengmengsinc@163.com 'wumengm' --verbose

    但是此时报下面这个错误 (身份认证失败,需要重新认证)

    错误

    2)重新认证:

    pod trunk register mengmengsinc@163.com 'wumengm' --description='ceshi'

    3)验证是否注册成功:

    pod trunk me

    验证成功

    4.本地创建pod库

    利用命令行创建peoject:(之前文章https://www.jianshu.com/p/fbcb9977274b最后有写过上传组件用到的pods创建方式)

    pod lib create JHIMComponets

    创建成功

    5.配置podspec

      s.source对应之前创建的git远程仓库地址就好。其他不用改

    podspec

    6.添加pod具体内容

    1)在目录class中加入 componet文件,并在componet中加入一个用于测试的方法。

    加入文件

    2)cd到Example路径下,执行pod install 就能看到这个引用文件了

    pod install 后

    7.项目上传和发布

    # 添加github项目路径

    JHIMComponets % git remote add origin https://github.com/wumengm/JHTestComponets.git

    # 添加文件

    git add .

    # 将暂存区里的改动给提交到本地的版本库

    git commit-m "first commit"

    # 创建分支

    git branch-M main

    # 提交版本号并push到main分支

    git push-u origin main

    #注意这里的版本号要与.podspec中的版本号保持一致

    git tag 0.1.0

    git push origin 0.1.0

    注意:::

    在执行git push -u origin main的时候如果遇到需要输入用户名和密码

    这个密码不是你Github的登录密码,而是需要生成一个access tokens。

    生成token步骤:需要在Github个人设置页 -> Settings -> Developer settings -> Personal access tokens 中创建一个token。

    tokens创建一个新的 需要勾选(1) 需要勾选(2)

    所有的执行完毕,就能去Git查看

    上传成功

    8.使用

    1)在一个使用pod的项目中 podfile中加入上传的组件

    加入组件

    2)pod install 更新 后就能看到项目中有了

    有了

    3)由于是写的Oc组件,项目为Swift,则加入桥接文件WMModules01-Bridging-Header,并在里面导入组件头文件

    头文件

    4)使用

    相关文章

      网友评论

          本文标题:Pod本地组件传到Github

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