iOS 远程私有库

WechatIMG13.jpeg

一: 创建pod项目工程文件

  pod lib create ConsultantBase  ##ConsultantBase  你要创建的pod名字
1.png

之后生成的文件目录结构是这样的

2.png

我们需要需要将replaceMe替换为我们自己的文件,效果图如下:


WechatIMG14.jpeg
屏幕快照 2017-04-12 下午3.14.18.png

然后进入Example文件夹执行pod update命令,再打开项目工程可以看到,刚刚添加的组件已经在Pods子工程下Development ConsultantBase/ConsultantBase中了。

二: 修改ConsultantBase.podspec文件,和远程的链接关联

```
  Pod::Spec.new do |s|
  s.name             = 'ConsultantBase'
  s.version          = '0.1.0'
  s.summary          = 'ConsultantBase.'
  s.description      = <<-DESC
      Add long description of the pod here.
                   DESC

  s.homepage         =     'https://coding.net/u/Mikes/p/ConsultantSpecs'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'Kenvin' => 'yaoyj@oriental-finance.com' }
  s.source           = { :git => 'https://git.coding.net/Mikes/ConsultantBase.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
  s.ios.deployment_target = '8.0'
  s.source_files = 'ConsultantBase/Classes/**/*'

  # s.resource_bundles = {
     #   'ConsultantBase' => ['ConsultantBase/Assets/*.png']
  # }

  # s.public_header_files = 'Pod/Classes/**/*.h'
  # s.frameworks = 'UIKit', 'MapKit'
  # s.dependency 'AFNetworking', '~> 2.3'
end
```

二: 本地库和远程关联

在远端添加远端仓库


WechatIMG15.jpeg
git add .
git commit -m "Initial ConsultantBase "
#添加远端仓库
git remote add origin https://git.coding.net/Mikes/xxxx.git  
#推送到远端仓库
git push origin master

对本地库添加tag标签

 git tag 0.1.0
git push --tag

之后对本地库进行校验

   pod spec lint --allow-warnings

如果成功,返回:


 -> ConsultantBase (0.1.0)
    - WARN  | [iOS] xcodebuild:  ConsultantBase/ConsultantBase/Classes/Category/UITextView+SMKLimitTips.m:153:73: warning: values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead [-Wformat]
Analyzed 1 podspec.
ConsultantBase.podspec passed validation.

如果失败

~:ConsultantBase Kenvin$ pod lib lint

-> ConsultantBase (0.1.0)
   - WARN  | [iOS] xcodebuild:  /Users/Kenvin/remoteLib/ConsultantBase/ConsultantBase/Classes/Category/UITextView+SMKLimitTips.m:153:73: warning: values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead [-Wformat]

[!] ConsultantBase did not pass validation, due to 1 warning (but you can use `--allow-warnings` to ignore it).
[!] The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a `.swift-version` file to set the version for your Pod. For example to use Swift 2.3, run: 
   `echo "2.3" > .swift-version`.
You can use the `--no-clean` option to inspect any issue.

解决方案是:

~:ConsultantBase Kenvin$ echo "2.3" > .swift-version

三: 将pod组建和自己建立的pod索引库 xxSpecs 关联

   pod repo add ConsultantSpecs     https://git.coding.net/Mikes/xxxxSpecs.git

执行:

    pod repo

结果:


artsy
- Type: git (master)
- URL:  https://github.com/Artsy/Specs.git
- Path: /Users/Kenvin/.cocoapods/repos/artsy

ConsultantSpecs
- Type: git (master)
- URL:  https://git.coding.net/Mikes/ConsultantSpecs.git
- Path: /Users/Kenvin/.cocoapods/repos/ConsultantSpecs

master
- Type: git (master)
- URL:  https://github.com/CocoaPods/Specs.git
- Path: /Users/Kenvin/.cocoapods/repos/master

3 repos

四:向Spec Repo提交podspec文件

pod  repo push ConsultantSpecs ConsultantBase.podspec

结果:

WechatIMG16.jpeg

五:使用制作好的Pod

在正式项目的Podfile 里添加私有Spec Repo

source 'https://git.coding.net/Mikes/ConsultantSpecs.git' 
pod 'ConsultantBase', '~> 0.1.0'

然后执行pod update,更新库依赖,然后打开项目可以看到,我们自己的库文件已经出现在Pods子项目中的Pods子目录下了,而不再是Development Pods。

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

推荐阅读更多精彩内容