iOS cocoapods创建库

作者: GA_ | 来源:发表于2018-08-04 16:05 被阅读6次
    查看注册过得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语言版本

    相关文章

      网友评论

        本文标题:iOS cocoapods创建库

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