美文网首页iOS开发技巧
创建自己的cocoapods库

创建自己的cocoapods库

作者: 天空像天空一样蓝 | 来源:发表于2018-04-19 17:22 被阅读6次

最近在整理自己的简历,发现简历上面没有拿的出手的干货,都是一些“负责什么界面、维护什么迭代”,全是业务、业务、业务。
创建cocoapods库过程中全程自己摸索,很苦逼,很蛋疼
创建空文件 用于承载pod给你创建好的工程

  • 在终端下输入 pod lib create xxxx(你的库名)


    Snip20180419_16.png

然后提示你会让你回答几个问题,注意大小字母和空格的问题

  • 然后会自动为你创建一个工程,并自动打开,这里让你省很多事(在没有找到这个方法事自己在坑里面转了几个小时)


    Snip20180419_17.png

此时已经进行到一半了,进入我们熟悉的Xcode中


Snip20180419_18.png
  • 看到我们的工程中有一个XXX.podspec文件,在这里面配置我们的信息,改动的地方很少。
    但是注意
    “s.description” 文字一定要比“s.summary ”长,否则等会验证会出现error
    红框的地方就是我们的库代码

输入下面的代码,验证我们的配置文件有没有错误,很坑很坑很坑很坑

➜  GCYBase git:(master) pod lib lint GCYBase.podspec 

 -> GCYBase (0.1.0)

GCYBase passed validation.
  • 要是如上图那么恭喜你了,可以进行下一步操作,提交到Git上
    此时我们的Git上是没有这个工程的,所以我们要去创建一个新的工程,
    Repository name 就是你的库名字
    其他的都不要选择了,语法和证书都不要选,否则会有冲突的,因为上面已经自动给你创建了一个工程,里面已经包含了下面的配置信息。
Snip20180419_19.png
git add . 
git commit -m “Initial Commit" 
git remote add origin https://github.com/xxx/xxx.git 
git push -u origin master
  • 最后的验证,要是没有问题,就如下图显示
➜  GCYBase git:(master) ✗ pod spec lint GCYBase.podspec

 -> GCYBase (0.1.2)

Analyzed 1 podspec.

GCYBase.podspec passed validation.

  • 最后提交我们的pod 这个是失败的,更新pod就可以了
➜  GCYBase git:(master) ✗ pod trunk push GCYBase.podspec 
Updating spec repo `master`
[!] CocoaPods was not able to update the `master` repo. If this is an unexpected issue and persists you can inspect it running `pod repo update --verbose`
➜  GCYBase git:(master) 

根据提示运行

➜  GCYBase git:(master) pod repo update --verbose

等待pod更新完成


Snip20180419_21.png

重新运行 pod trunk push GCYBase.podspec 总于等到你

➜  GCYBase git:(master) ✗ pod trunk push GCYBase.podspec
Updating spec repo `master`

CocoaPods 1.5.0 is available.
To update use: `sudo gem install cocoapods`

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.5.0

Validating podspec
 -> GCYBase (0.1.2)

Updating spec repo `master`

CocoaPods 1.5.0 is available.
To update use: `sudo gem install cocoapods`

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.5.0


--------------------------------------------------------------------------------
 🎉  Congrats

 🚀  GCYBase (0.1.2) successfully published
 📅  April 19th, 03:50
 🌎  https://cocoapods.org/pods/GCYBase
 👍  Tell your friends!
--------------------------------------------------------------------------------
➜  GCYBase git:(master) ✗ 

然后就是默默的等待吧,大概两个工作日
可以通过 search xxx 查找自己的pod

相关文章

网友评论

    本文标题:创建自己的cocoapods库

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