iOS cocoapods创建库

查看注册过得trunk
houjianan:~> pod trunk me
[!] You need to register a session first.
Usage:
    $ pod trunk me COMMAND
      Includes information about your registration, followed by all your
      sessions.
      These are your current session, other valid sessions, unverified sessions,
      and expired sessions.
Commands:
    + clean-sessions  Remove sessions
Options:
    --silent          Show nothing
    --verbose          Show more debugging information
    --no-ansi          Show output without ANSI codes
    --help            Show help banner of specified command
注册
houjianan:~> pod trunk register [58895347@qq.com](mailto:58895347@qq.com)"kongzichixiangjiao" --verbose
opening connection to [trunk.cocoapods.org:443](http://trunk.cocoapods.org:443/)...

opened

starting SSL for [trunk.cocoapods.org:443](http://trunk.cocoapods.org:443/)...

SSL established

<- "POST /api/v1/sessions HTTP/1.1\r\nContent-Type: application/json; charset=utf-8\r\nAccept: application/json; charset=utf-8\r\nUser-Agent: CocoaPods/1.5.3\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nHost: [trunk.cocoapods.org](http://trunk.cocoapods.org/)\r\nContent-Length: 74\r\n\r\n"

<- "{\"email\":\"[58895347@qq.com](mailto:58895347@qq.com)\",\"name\":\"kongzichixiangjiao\",\"description\":null}"

-> "HTTP/1.1 201 Created\r\n"

-> "Date: Fri, 03 Aug 2018 05:55:44 GMT\r\n"

-> "Connection: keep-alive\r\n"

-> "Strict-Transport-Security: max-age=31536000\r\n"

-> "Content-Type: application/json\r\n"

-> "Content-Length: 193\r\n"

-> "X-Content-Type-Options: nosniff\r\n"

-> "Server: thin 1.6.2 codename Doc Brown\r\n"

-> "Via: 1.1 vegur\r\n"

-> "\r\n"

reading 193 bytes...

-> "{\"created_at\":\"2018-08-03 05:55:43 UTC\",\"valid_until\":\"2018-12-09 05:55:43 UTC\",\"verified\":false,\"created_from_ip\":\"112.35.33.186\",\"description\":null,\"token\":\"cf5d9d6ea965e4988c68930b1956d89f\"}"

read 193 bytes

Conn keep-alive
提示登录邮箱认证
[!] Please verify the session by clicking the link in the verification email that has been sent to [58895347@qq.com](mailto:58895347@qq.com)
没登录邮箱
houjianan:~> pod trunk me
[!] Authentication token is invalid or unverified. Either verify it with the email that was sent or register a new session.
登录邮箱
邮件内容.png

浏览器打开链接地址


打开浏览器中链接.png
再次trunk me
houjianan:~> pod trunk me
  - Name:     kongzichixiangjiao
  - Email:    [58895347@qq.com](mailto:58895347@qq.com)
  - Since:    August 2nd, 23:55
  - Pods:     None
  - Sessions:
    - August 2nd, 23:55 - December 8th, 23:59\. IP: 112.35.33.186
创建项目
创建项目.png
创建成功之后 克隆下来 添加公开库文件
128A5EB9-DF31-4C10-A387-60CEF999CBF0.png
cd到项目下
houjianan:~> cd /Users/houjianan/Documents/GitHub/YYLoginTextFeild 

houjianan:YYLoginTextFeild> ls

LICENSE[README.md](http://readme.md/)runtime

houjianan:YYLoginTextFeild> 
echo "4.1"  .swift-version
创建 .podspec文件
houjianan:YYLoginTextFeild> pod spec create YYLoginTextFeild
Specification created at YYLoginTextFeild.podspec

houjianan:YYLoginTextFeild> 
编辑 .podspec文件
#

#  Be sure to run `pod spec lint YYLoginTextFeild.podspec' to ensure this is a

#  valid spec and to remove all comments including this before submitting the spec.

#

#  To learn more about Podspec attributes see [http://docs.cocoapods.org/specification.html](http://docs.cocoapods.org/specification.html)

#  To see working Podspecs in the CocoaPods repo see [https://github.com/CocoaPods/Specs/](https://github.com/CocoaPods/Specs/)

#

Pod::Spec.new do |s|

  # ―――  Spec Metadata  ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #

  #

  #  These will help people to find your library, and whilst it

  #  can feel like a chore to fill in it's definitely to your advantage. The

  #  summary should be tweet-length, and the description more in depth.

  #

名称 [s.name](http://s.name/)        = "YYLoginTextFeild"

版本号 s.version      = "0.0.1"

简介 s.summary      = "登录、注册、验证码输入框样式"

  # This description is used to generate tags and improve search results.

  #   * Think: What does it do? Why did you write it? What is the focus?

  #   * Try to keep it short, snappy and to the point.

  #   * Write the description between the DESC delimiters below.

  #   * Finally, don't worry about the indent, CocoaPods strips it!

  s.description  = <<-DESC

                        登录、注册、验证码输入框样式

                   DESC

项目主地址 s.homepage     = "[https://github.com/kongzichixiangjiao/YYLoginTextFeild](https://github.com/kongzichixiangjiao/YYLoginTextFeild)"

  # s.screenshots  = "[www.example.com/screenshots_1.gif](http://www.example.com/screenshots_1.gif)", "[www.example.com/screenshots_2.gif](http://www.example.com/screenshots_2.gif)"

  # ―――  Spec License  ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #

  #

  #  Licensing your code is important. See [http://choosealicense.com](http://choosealicense.com/)for more info.

  #  CocoaPods will detect a license file if there is a named LICENSE*

  #  Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.

  #

许可证 s.license      = "MIT"

  # s.license      = { :type => "MIT", :file => "FILE_LICENSE" }

  # ――― Author Metadata  ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #

  #

  #  Specify the authors of the library, with email addresses. Email addresses

  #  of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also

  #  accepts just a name if you'd rather not provide an email address.

  #

  #  Specify a social_media_url where others can refer to, for example a twitter

  #  profile URL.

  #

作者 s.author             = { "kongzichixiangjiao" => ["58895347@qq.com](mailto:%2258895347@qq.com)" }

  # Or just: s.author    = "kongzichixiangjiao"

  # s.authors            = { "kongzichixiangjiao" => ["58895347@qq.com](mailto:%2258895347@qq.com)" }

社交地址 # s.social_media_url   = "[http://twitter.com/kongzichixiangjiao](http://twitter.com/kongzichixiangjiao)"

  # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #

  #

  #  If this Pod runs only on iOS or OS X, then specify the platform and

  #  the deployment target. You can optionally include the target after the platform.

  #

  # s.platform     = :ios

  # s.platform     = :ios, "5.0"

  #  When using multiple platforms

  # s.ios.deployment_target = "5.0"

  # s.osx.deployment_target = "10.7"

  # s.watchos.deployment_target = "2.0"

  # s.tvos.deployment_target = "9.0"

  # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #

  #

  #  Specify the location from where the source should be retrieved.

  #  Supports git, hg, bzr, svn and HTTP.

  #

项目地址(github地址)  s.source       = { :git => "[https://github.com/kongzichixiangjiao/YYLoginTextFeild](https://github.com/kongzichixiangjiao/YYLoginTextFeild)[.git](http://example/YYLoginTextFeild.git)", :tag => "#{s.version}" }

  # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #

  #

  #  CocoaPods is smart about how it includes source code. For source files

  #  giving a folder will include any swift, h, m, mm, c & cpp files.

  #  For header files it will include any header in the folder.

  #  Not including the public_header_files will make all headers public.

  #

是否包含源文件  s.source_files  = 'runtime/*', 'runtime/runtime/*.{h,m}', 'runtime//**/*.h'

  s.exclude_files = "Classes/Exclude"

公开的头文件 # s.public_header_files = "Classes/**/*.h"

  # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #

  #

  #  A list of resources included with the Pod. These are copied into the

  #  target bundle with a build phase script. Anything else will be cleaned.

  #  You can preserve files from being cleaned, please don't preserve

  #  non-essential files like tests, examples and documentation.

  #

  # s.resource  = "icon.png"

资源文件 # s.resources = "Resources/*.png"

  # s.preserve_paths = "FilesToSave", "MoreFilesToSave"

  # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #

  #

  #  Link your library with frameworks, or libraries. Libraries do not include

  #  the lib prefix of their name.

  #

  s.framework  = “UIKit"

  # s.frameworks = "SomeFramework", "AnotherFramework"

  # s.library   = "iconv"

  # s.libraries = "iconv", "xml2"

  # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #

  #

  #  If your library depends on compiler flags you can set them in the xcconfig hash

  #  where they will only apply to your library. If you depend on other Podspecs

  #  you can include multiple dependencies to ensure it works.

是否支持ARC # s.requires_arc = true

  # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }

依赖库 # s.dependency ‘AFNetworking’, ‘…’, ‘…'

end
可以直接复制下面部分进行修改
Pod::Spec.new do |s|

  s.name         = "YYLoginTextFeild" # 项目名称

  s.version      = "0.1.8"        # 版本号 与 你仓库的 标签号 对应

  s.license      = "MIT"          # 开源证书

  s.summary      = "YYLoginTextFeild" # 项目简介

  s.homepage     = "[https://github.com/kongzichixiangjiao/YYLoginTextFeild](https://github.com/kongzichixiangjiao/YYLoginTextFeild)" # 你的主页

  s.source       = { :git => "[https://github.com/kongzichixiangjiao/YYLoginTextFeild.git](https://github.com/kongzichixiangjiao/YYLoginTextFeild.git)", :tag => "#{s.version}" }#你的仓库地址,不能用SSH地址

  s.source_files = "YYLoginTextFeild/Classes/**/*" # "Classes/*.{h,m,swift}" # 你代码的位置, Classes/*.{h,m} 表示 Classes 文件夹下所有的.h和.m文件

  #资源文件地址

  s.resource = 'YYLoginTextFeild/Source.bundle'

  s.requires_arc = true # 是否启用ARCS

  s.platform     = :ios, "9.0" #平台及支持的最低版本

  s.frameworks   = "UIKit", "Foundation" #支持的框架

  # s.dependency = "AFNetworking" # 依赖库

  # User

  s.author             = { "BY" => "[houjianan_110@163.com](mailto:houjianan_110@163.com)" } # 作者信息

  s.social_media_url   = "[https://github.com/kongzichixiangjiao](https://github.com/kongzichixiangjiao)" # 个人主页

end
上传Git

打tag添加描述

houjianan:YYLoginTextFeild> git tag -a 0.0.2 -m "0.0.2"

推送到远程

houjianan:YYLoginTextFeild> git push --tags

删除本地tag

houjianan:YYLoginTextFeild> git tag -d 0.0.2

删除远程tag

houjianan:YYLoginTextFeild> git push origin :refs/tags/0.0.2
先校验 .podspec 文件
houjianan:YYLoginTextFeild> pod lib lint
可能遇到的错误信息
houjianan:GitHub> pod spec lint YYLoginTextFeild.podspec —verbose

// 需要更改YYLoginTextFeild.podspec信息

[!] Unable to find a spec named `YYLoginTextFeild.podspec'.

houjianan:YYLoginTextFeild> pod spec lint YYLoginTextFeild.podspec --verbose

    YYLoginTextFeild (0.0.1) - Analyzing on macOS platform.

  Preparing

Analyzing dependencies

Inspecting targets to integrate

  Using `ARCHS` setting to build architectures of target `Pods-App`: (``)

Fetching external sources

-> Fetching podspec for `YYLoginTextFeild` from `/Users/houjianan/Documents/GitHub/YYLoginTextFeild/YYLoginTextFeild.podspec`

 -> YYLoginTextFeild (0.0.1)

    - ERROR | license: Sample license type.

    - WARN  | homepage: The homepage has not been updated from default

    - WARN  | summary: The summary is not meaningful.

    - ERROR | description: The description is empty.

    - WARN  | url: There was a problem validating the URL [http://EXAMPLE/YYLoginTextFeild](http://example/YYLoginTextFeild).

[!] Error installing YYLoginTextFeild

 -> YYLoginTextFeild (0.0.1)

    - WARN  | description: The description is shorter than the summary.

tag和.podspec文件内版本号没有对应上

    - ERROR | [OSX] unknown: Encountered an unknown error ([!] /usr/bin/git clone [https://github.com/kongzichixiangjiao/YYLoginTextFeild.git](https://github.com/kongzichixiangjiao/YYLoginTextFeild.git)/var/folders/lt/wny5lssx58x_hkdk7s2wrnf80000gn/T/d20180803-12648-1tgkbs2 --template= --single-branch --depth 1 --branch 0.0.1

Cloning into '/var/folders/lt/wny5lssx58x_hkdk7s2wrnf80000gn/T/d20180803-12648-1tgkbs2'...

warning: Could not find remote branch 0.0.1 to clone.

fatal: Remote branch 0.0.1 not found in upstream origin
houjianan:YYLoginTextFeild> pod lib lint

 -> YYLoginTextFeild (0.0.4)

    - ERROR | [iOS] unknown: Encountered an unknown error (Malformed version number string ) during validation.

[!] YYLoginTextFeild did not pass validation, due to 1 error.

You can use the `--no-clean` option to inspect any issue.

houjianan:YYLoginTextFeild> pod lib lint --allow-warnings

houjianan:YYLoginTextFeild> pod lib lint --no-clean

 -> YYLoginTextFeild (0.0.4)

    - ERROR | [iOS] unknown: Encountered an unknown error (Malformed version number string ) during validation.

Pods workspace available at `/var/folders/bt/5xj1rgx15xl827n7bvgyl9lc0000gn/T/CocoaPods-Lint-20180804-17109-148py73-YYLoginTextFeild/App.xcworkspace` for inspection.

[!] YYLoginTextFeild did not pass validation, due to 1 error.

houjianan:YYLoginTextFeild> pod lib lint

 -> YYLoginTextFeild (0.0.4)

    - ERROR | [iOS] unknown: Encountered an unknown error (Malformed version number string ) during validation.

[!] YYLoginTextFeild did not pass validation, due to 1 error.

You can use the `--no-clean` option to inspect any issue.

houjianan:YYLoginTextFeild> pod lib lint --allow-warnings

 -> YYLoginTextFeild (0.0.4)

    - ERROR | [iOS] unknown: Encountered an unknown error (Malformed version number string ) during validation.

[!] YYLoginTextFeild did not pass validation, due to 1 error.

You can use the `--no-clean` option to inspect any issue.

houjianan:YYLoginTextFeild> git tag -a 0.0.5

fatal: no tag message?

houjianan:YYLoginTextFeild> git tag -a 0.0.5 -m "0.0.5"

houjianan:YYLoginTextFeild> git push --tags

Counting objects: 1, done.

Writing objects: 100% (1/1), 159 bytes | 159.00 KiB/s, done.

Total 1 (delta 0), reused 0 (delta 0)

To [https://github.com/kongzichixiangjiao/YYLoginTextFeild.git](https://github.com/kongzichixiangjiao/YYLoginTextFeild.git)

 * [new tag]         0.0.5 -> 0.0.5

houjianan:YYLoginTextFeild> pod lib lint --allow-warnings

 -> YYLoginTextFeild (0.0.5)

    - ERROR | [iOS] unknown: Encountered an unknown error (Malformed version number string ) during validation.

[!] YYLoginTextFeild did not pass validation, due to 1 error.

You can use the `--no-clean` option to inspect any issue.

houjianan:YYLoginTextFeild> ls

LICENSEYYLoginTextFeild

[README.md](http://readme.md/)YYLoginTextFeild.podspec

houjianan:YYLoginTextFeild> pod lib lint

 -> YYLoginTextFeild (0.0.5)

    - ERROR | [iOS] unknown: Encountered an unknown error (Malformed version number string ) during validation.

[!] YYLoginTextFeild did not pass validation, due to 1 error.

You can use the `--no-clean` option to inspect any issue.

上面的问题解决如下 不明白为啥

houjianan:YYLoginTextFeild> sudo gem install -n /usr/local/bin cocoapods

Successfully installed cocoapods-1.5.3

Parsing documentation for cocoapods-1.5.3

Installing ri documentation for cocoapods-1.5.3

Done installing documentation for cocoapods after 2 seconds

1 gem installed

本地验证成功
 -> YYLoginTextFeild (0.0.1)

YYLoginTextFeild passed validation.
发布
houjianan:YYLoginTextFeild> pod trunk push YYLoginTextFeild.podspec 
Updating spec repo `master`

warning: inexact rename detection was skipped due to too many files.

warning: you may want to set your diff.renameLimit variable to at least 17613 and retry the command.

CocoaPods 1.5.3 is available.

To update use: sudo gem install cocoapods

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

Validating podspec

发布成功成功

houjianan:YYLoginTextFeild> pod trunk push YYLoginTextFeild.podspec 
Updating spec repo `master`

CocoaPods 1.5.3 is available.

To update use: `sudo gem install cocoapods`

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

Validating podspec

 -> YYLoginTextFeild (0.0.2)

Updating spec repo `master`

CocoaPods 1.5.3 is available.

To update use: `sudo gem install cocoapods`

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

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

 🎉  Congrats

 🚀  YYLoginTextFeild (0.0.2) successfully published

 📅  August 3rd, 21:37

 🌎  [https://cocoapods.org/pods/YYLoginTextFeild](https://cocoapods.org/pods/YYLoginTextFeild)

 👍  Tell your friends!

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

houjianan:YYLoginTextFeild>
bundle图片资源直接给文件夹加后缀
注意framework里面获取图片使用方法
90E9B29C-7EAB-45C5-A14A-A9C4BE02A89F.png
登录网站检查

https://cocoapods.org/pods/YYLoginTextFeild

image.png

整体流程如下:

1、查看注册过得trunk
houjianan:~> pod trunk me
2、注册
houjianan:~> pod trunk register 58895347@qq.com"kongzichixiangjiao" --verbose
3、登录邮箱
4、浏览器打开邮件链接链接地址
5、再次trunk me
houjianan:~> pod trunk me
6、托管平台使用Github,Github上创建项目
7、克隆项目到本地
8、终端进入克隆项目的目录
9、创建 .podspec文件并且编辑
10、设置swift语言版本
echo “4.1" .swift-version
11、打tag、上传到Git
12、验证
houjianan:YYLoginTextFeild> pod lib lint
13、发布
houjianan:YYLoginTextFeild> pod trunk push YYLoginTextFeild.podspec
14、检查
https://cocoapods.org/pods/YYLoginTextFeild
15、使用
cocoapods 正常操作就可以
16、修改库之后,修改.podspec版本,重复11-14步

注意:

1、tag版本那必须跟 .podspec内版本对应上
2、注意文件路径
3、bundle资源的使用
4、cocoapods的版本
5、swift语言版本

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

推荐阅读更多精彩内容