创建 pod 私有库上传 cocoapods

一、创建 library

  1. 使用 pod 命令创建 lib
> pod lib create JKCache
  • 运行结果
Cloning `https://github.com/CocoaPods/pod-template.git` into `JKCache`.
Configuring JKCache template.
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.

------------------------------

To get you started we need to ask a few questions, this should only take a minute.

If this is your first time we recommend running through with the guide:
 - https://guides.cocoapods.org/making/using-pod-lib-create.html
 ( hold cmd and click links to open in a browser. )
...
  1. 自选配置
  • 平台: 选择 iOSMAC
What platform do you want to use?? [ iOS / macOS ]
 > iOS
  • 开发语言:SwiftObjC
What language do you want to use?? [ Swift / ObjC ]
 > ObjC
  • 自动生产 Demo 工程 YesNo
Would you like to include a demo application with your library? [ Yes / No ]
 > Yes
  • 测试框架 SpectaKiwiNone
Which testing frameworks will you use? [ Specta / Kiwi / None ]
 > None
  • 基于试图测试 YesNo
Would you like to do view based testing? [ Yes / No ]
 > Yes
  • 项目前缀
What is your class prefix?
 > JK
  • 运行结果
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.

Running pod install on your new library.

Analyzing dependencies
Adding spec repo `trunk` with CDN `https://cdn.cocoapods.org/`

CocoaPods 1.9.3 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.9.3

Downloading dependencies
...
Installing JKCache (0.1.0)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `JKCache.xcworkspace` for this project from now on.
Pod installation complete! There are 5 dependencies from the Podfile and 5 total pods installed.

 Ace! you're ready to go!
 We will start you off by opening your project in Xcode
  open 'JKCache/Example/JKCache.xcworkspace'

To learn more about the template see `https://github.com/CocoaPods/pod-template.git`.
To learn more about creating a new pod, see `https://guides.cocoapods.org/making/making-a-cocoapod`.

library 在当前目录下创建成功

二、编辑 library

  1. copy 类文件至··/libName/Classes 文件夹
    类文件位置
  2. copy 资源文件至··/libName/Assets 文件夹
    资源文件位置
  3. 编辑 podspec 文件
Pod::Spec.new do |s|
  s.name             = 'JKCache'
  s.version          = '0.1.0'
  s.summary          = '轻量级缓存库'

# 描述
  s.description      = <<-DESC
                        适用于 OC 开发 下的一个轻量级缓存框架
                       DESC
# 主页
  s.homepage         = 'https://github.com/jack6231/JKCache'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'jack6231' => '**********@163.com' }
# 仓库地址,tag 与 version 一致
  s.source           = { :git => 'https://github.com/jack6231/JKCache.git', :tag => s.version.to_s }

  s.ios.deployment_target = '8.0'

# 类文件位置
  s.source_files = 'JKCache/Classes/**/*'

# 资源文件位置  
  s.resource_bundles = {
    'JKCache' => ['JKCache/Assets/*.png']
  }

end
  1. 完善 Demo


    Demo 位置

三、上传 gitHub

  1. GitHub 上创建项目
  2. 上传 library 至 gitHub
  3. 创建tag、推送远程仓库
> git tag 0.1.0
> git push origin 0.1.0

四、注册 cocoapods 账号

  1. 使用 pod 命令注册 cocoapods 账号
> pod trunk register ***********@163.com "Jack" --verbose
  • pod 会将验证链接发送至注册邮箱
  • 点击邮箱验证链接,继续完成注册
  1. 查看自己的注册信息
> pod trunk me
  • 注册信息
  - Name:     Jack
  - Email:    **********1@163.com
  - Since:    June 3rd, 21:14
  - Pods:
    - JKCache
  - Sessions:
    - June 3rd, 21:14 - October 29th, 03:04. IP: 211.94.117.100

五、将 library 同步 cocoapods 索引库

  1. 添加私有库索引库
> pod repo add JKCache https://github.com/jack6231/JKCache.git
  • 添加成功
Cloning spec repo `JKCache` from `https://github.com/jack6231/JKCache.git`
  • 查看 repo list
> pod repo
cocoapods
- Type: git (master)
- URL:  https://github.com/CocoaPods/Specs.git
- Path: /Users/jack/.cocoapods/repos/cocoapods

JKCache
- Type: git (master)
- URL:  https://github.com/jack6231/JKCache.git
- Path: /Users/jack/.cocoapods/repos/JKCache

trunk
- Type: CDN
- URL:  https://cdn.cocoapods.org/
- Path: /Users/jack/.cocoapods/repos/trunk

3 repos
  1. 验证私有库
> pod lib lint
  • 验证通过
 -> JKCache (0.1.0)
    - NOTE  | xcodebuild:  note: Using new build system
    - NOTE  | xcodebuild:  note: Building targets in parallel
    - NOTE  | [iOS] xcodebuild:  note: Planning build
    - NOTE  | [iOS] xcodebuild:  note: Constructing build description
    - NOTE  | [iOS] xcodebuild:  warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')
    - NOTE  | [iOS] xcodebuild:  note: Execution policy exception registration failed and was skipped: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" (in target 'JKCache' from project 'Pods')
    - NOTE  | [iOS] xcodebuild:  note: Execution policy exception registration failed and was skipped: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" (in target 'Pods-App' from project 'Pods')
    - NOTE  | [iOS] xcodebuild:  note: Execution policy exception registration failed and was skipped: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" (in target 'App' from project 'App')

JKCache passed validation.
  • 如果检查有错误警告,可以使用 Demo 工程调试
  1. 同步 library 索引至 cocoapods 索引库
> pod trunk push JKCache.podspec --use-libraries --allow-warnings
  • 同步成功
--------------------------------------------------------------------------------
 🎉  Congrats

 🚀  JKCache (0.1.0) successfully published
 📅  June 4th, 00:16
 🌎  https://cocoapods.org/pods/JKCache
 👍  Tell your friends!
--------------------------------------------------------------------------------
  1. 验证是否成功提交 cocoapods
  • 移除刚才添加私有库 repo
> pod repo remove JKCache
> pod repo
cocoapods
- Type: git (master)
- URL:  https://github.com/CocoaPods/Specs.git
- Path: /Users/jack/.cocoapods/repos/cocoapods

trunk
- Type: CDN
- URL:  https://cdn.cocoapods.org/
- Path: /Users/jack/.cocoapods/repos/trunk

2 repos
  • 更新索引库
> pod repo update
  • pod search 刚才上传的私有库
> pod search JKCache
-> JKCache (0.1.0)
   轻量级缓存库
   pod 'JKCache', '~> 0.1.0'
   - Homepage: https://github.com/jack6231/JKCache
   - Source:   https://github.com/jack6231/JKCache.git
   - Versions:  0.1.0 [cocoapods repo]
  • 添加成功

提交成功审核需要一定时间,隔天再搜索看是否搜索的到
所有私有库,需要将自己添加的 repo 移除
若库有更新重新执行 步骤五

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,362评论 5 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,330评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,247评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,560评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,580评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,569评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,929评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,587评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,840评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,596评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,678评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,366评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,945评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,929评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,165评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,271评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,403评论 2 342