创建私有库并关联(未整理)

创建私有库

首先需要在自己的gitlab/CSDN/码云等账号上,创建两个项目,一个是specs的,一个是自己要封装的,如下图所示


image.png

第一步创建仓库


image.png

image.png

第二步创建lib文件 2.1 选择lib文件需要保存的路径

2.2 打开终端进入lib文件路径

2.3 终端输入pod lib create MyLibrary命令,根据问题依次输入自己项目的需求,如下:

~/Lib » pod lib create NWFDraggableView

Cloning https://github.com/CocoaPods/pod-template.git into NWFDraggableView.

Configuring NWFDraggableView template.


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:

( hold cmd and double click links to open in a browser. )

What platform do you want to use?? [ iOS / macOS ] > iOS

What language do you want to use?? [ Swift / ObjC ] > Objc

Would you like to include a demo application with your library? [ Yes / No ] > Yes

Which testing frameworks will you use? [ Specta / Kiwi / None ] > None

Would you like to do view based testing? [ Yes / No ] > Yes

What is your class prefix? > NWF

Running pod install on your new library.

Analyzing dependencies

Fetching podspec for NWFDraggableView from ../

Downloading dependencies

Installing FBSnapshotTestCase (2.1.4)

Installing NWFDraggableView (0.1.0)

Generating Pods project

Integrating client project

[!] Please close any current Xcode sessions and use NWFDraggableView.xcworkspace for this project from now on.

Sending stats

Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed.

Ace! you're ready to go!

We will start you off by opening your project in Xcode

open 'NWFDraggableView/Example/NWFDraggableView.xcworkspace'

To learn more about the template see https://github.com/CocoaPods/pod-template.git.

To learn more about creating a new pod, see http://guides.cocoapods.org/making/making-a-cocoapod.

一个lib文件创建了,可以参考官网 [Using Pod Lib Create

](https://guides.cocoapods.org/making/using-pod-lib-create.html)

2.4 lib文件创建后,导入自己封装好的文件

2.4.1 拷贝自己封装的文件到MyLibrary/MyLibrary/Classes/文件夹下,并且删除ReplaceMe.m文件


image.png

2.4.2 终端进入到MyLibrary/Example/ 路径,执行pod install 命令,这样你添加的封装文件就安装到测试项目里了

~/Lib » cd NWFDraggableView/Example


~/Lib/NWFDraggableView/Example(master*) » pod install

Analyzing dependencies

Fetching podspec for NWFDraggableView from ../

Downloading dependencies

Using FBSnapshotTestCase (2.1.4)

Using NWFDraggableView (0.1.0)

Generating Pods project

Integrating client project

Sending stats

Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed.

2.4.3 在ViewController文件中写测试代码

关联码云和本地的项目

关联好了本地项目和码云的项目之后,修改NWFBannerView.podspec文件,添加tag

Spec文件校验

先添加pod repo pod repo add NWFGiteeSpecs https://gitee.com/xiaoru/Specs.git

~/Lib/NWFDraggableView(master) » pod repo add NWFGiteeSpecs https://gitee.com/xiaoru/Specs.git

Cloning spec repo NWFGiteeSpecs from https://gitee.com/xiaoru/Specs.git

[!] /usr/bin/git clone https://gitee.com/xiaoru/Specs.git NWFGiteeSpecs

Cloning into 'NWFGiteeSpecs'...

fatal: unable to access 'https://gitee.com/xiaoru/Specs.git/': The requested URL returned error: 403


~/Lib/NWFDraggableView(master) » pod repo add NWFGiteeSpecs git@gitee.com:xiaoru/Specs.git

Cloning spec repo NWFGiteeSpecs from git@gitee.com:xiaoru/Specs.git

The authenticity of host 'gitee.com (120.55.226.24)' can't be established.

ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.

Are you sure you want to continue connecting (yes/no)? yes

[!] /usr/bin/git clone git@gitee.com:xiaoru/Specs.git NWFGiteeSpecs

Cloning into 'NWFGiteeSpecs'...

Warning: Permanently added 'gitee.com,120.55.226.24' (ECDSA) to the list of known hosts.

git@gitee.com: Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

添加公钥后

~/Lib/NWFDraggableView(master) » pod repo add NWFGiteeSpecs git@gitee.com:xiaoru/Specs.git

Cloning spec repo NWFGiteeSpecs from git@gitee.com:xiaoru/Specs.git

~/Lib/NWFDraggableView(master) » pod repo

master

NWFGiteeSpecs

  • Type: git (master)

  • URL: git@gitee.com:xiaoru/Specs.git

  • Path: /Users/judith/.cocoapods/repos/NWFGiteeSpecs

2 repos


~/Lib/NWFDraggableView(master) » pod spec lint

-> NWFDraggableView (0.1.0)

  • WARN | url: The URL (https://gitee.com/xiaoru/NWFDraggableView) is not reachable.

  • NOTE | xcodebuild: note: Using new build system

  • 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. (in target 'App')

Analyzed 1 podspec.

[!] The spec did not pass validation, due to 1 warning (but you can use --allow-warnings to ignore it).

因为我这个项目是私有的,只能访问到https://gitee.com/xiaoru 这个路径,所以修改 NWFDraggableView.podspec s.homepage = 'https://gitee.com/xiaoru'


~/Lib/NWFDraggableView(master) » pod spec lint

-> NWFDraggableView (0.1.0)

  • NOTE | xcodebuild: note: Using new build system

  • 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. (in target 'App')

Analyzed 1 podspec.

NWFDraggableView.podspec passed validation.


~/Lib/NWFDraggableView(master) » pod repo push NWFGiteeSpecs NWFDraggableView.podspec

Validating spec

-> NWFDraggableView (0.1.0)

  • NOTE | xcodebuild: note: Using new build system

  • 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. (in target 'App')

Updating the `NWFGiteeSpecs' repo

Already up to date.

Adding the spec to the `NWFGiteeSpecs' repo

  • [Add] NWFDraggableView (0.1.0)

Pushing the `NWFGiteeSpecs' repo


至此,spec文件和封装的组件化代码都上传至码云了,现在我们通过远程的方式来获取到码云上的组件化代码

~/Lib/NWFDraggableView/Example(master) » git push origin master

fatal: unable to access 'https://gitee.com/xiaoru/NWFDraggableView.git/': Could not resolve host: gitee.com


~/Lib/NWFDraggableView/Example(master) » git remote

origin


~/Lib/NWFDraggableView/Example(master) » git remote add origin git@gitee.com:xiaoru/NWFDraggableView.git

fatal: remote origin already exists.


~/Lib/NWFDraggableView/Example(master) » git config --global http.proxy


~/Lib/NWFDraggableView/Example(master) » git config --global https.proxy


~/Lib/NWFDraggableView/Example(master) » git push origin master

Counting objects: 15, done.

Delta compression using up to 4 threads.

Compressing objects: 100% (14/14), done.

Writing objects: 100% (15/15), 5.86 KiB | 2.93 MiB/s, done.

Total 15 (delta 7), reused 0 (delta 0)

remote: Powered By Gitee.com

To https://gitee.com/xiaoru/NWFDraggableView.git

d3e18fe..33318d9 master -> master


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