二、创建私有Pod

使用Cocoapods创建私有podspec

Pod存放位置

/.cocoapods/master

image.png

其中Specs-Repo是我的私有仓库

创建私有Spec Repo

创建一个pod工程

Using Pod Lib Create

pod lib create <ProjectName>

使用的时候可能会有如下错误:

Configuring AnimationProject template.
/Users/faterman/.rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- colored2 (LoadError)
    from /Users/faterman/.rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/faterman/Desktop/Mediator/AnimationProject/setup/TemplateConfigurator.rb:2:in `<top (required)>'
    from ./configure:5:in `require_relative'
    from ./configure:5:in `block in <main>'
    from ./configure:4:in `each'
    from ./configure:4:in `<main>'

此时依次运行下面两个命令,然后再次执行即可:

sudo gem install colored2
sudo gem update --system

这样就创建了一个Pod模版工程。其实刚才的操作分两步,一步是clone模版工程到本地,一步是按照脚本配置模版工程,你也可以自己fork一个template,然后改成自己的配置然后用自己的模版url创建即可。

新建的Pod模版项目的目录结构如下图所示:


image.png

其中Classes用来放置组件类,Example用来放例子工程。然后每次修改了Classes文件夹中的内容就要重新执行一遍Pod update。

将pod工程关联到私有git仓库中

  1. 使用Coding新建一个工程,名称相同。
  2. 执行以下命令
git add . #将本地修改提交到暂存区

git commit -m "Initial Commit of AnimationProject" #将本地修改提交到master分支

git remote add origin <git ssh url> #关联两个仓库

git push -u origin master #将本地master推送到remote master分支

git tag -m "first release" "0.1.0" #打个tag

git push --tags #将tag推送到远端仓库

修改podspec

打开实例工程中的podspec文件修改以下:

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容