zoukankan      html  css  js  c++  java
  • 让自己的开源项目支持CocoaPods

     测试的时候找个自己封装的方法或UI控件就可以了 这里用我刚封装的Redirect重定向的请求体为例

    1, 在github上创建一个Redirect,重要:记得选择开源协议 (MIT)(如果木有GitHub那先百度一下)

    2, 使用 Github Desktop Clone (克隆) Redirect 到电脑桌面 

    注: 修改Redirect文件里的东西记得及时更新,如何使用Github Desktop请百度

    3, cd到当前目录

    $ cd Redirect

    4, 创建一个podspec文件,命令:

    $ pod spec create Redirect

    5, 编辑 podspec文件,这里是用vim打开的,命令:(当然使用文本编辑器打开也可以)

    $ vim Redirect.podspec

    6, 创建之后会自动生成一个模板,里面会有详细的注释,我们只需要按需要修改这个文件即可,

    下边这个是测试的时候我编辑的 (如果需要更更多的配置 可以参考别的开源项目的podspec文件):

    (注: 以#开头的是可以删掉滴)

    Pod::Spec.new do |s|
    
    
    
      s.name         = "Redirect"
      s.version      = "0.0.1"
      s.summary      = "Redirecting Requests."
      s.description  = <<-DESC 
                              This is a Redirecting Requests.
                       DESC
      s.homepage     = "http://www.cnblogs.com/ljcgood66/"
      s.license      = "MIT"
      s.author       = { "LiJunCheng" => "1139981137@qq.com" }
      s.platform     = :ios
      s.source       = { :git => "https://github.com/ganlinmeng/Redirect.git", :tag =>"0.0.1" }
      s.source_files  = "Redirect", "Redirect/**/*.{h,m}"
      s.exclude_files = "Classes/Exclude"
      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.
    
      # s.requires_arc = true
    
      # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
      # s.dependency "JSONKit", "~> 1.4"
    
    end

    s.name:名称,pod search 搜索的关键词,注意这里一定要和.podspec的名称一样,否则报错
    s.version:版本号
    s.ios.deployment_target:支持的pod最低版本
    s.summary: 简介
    s.homepage:项目主页地址
    s.license:许可证
    s.author:作者
    s.social_media_url:社交网址
    s.source:项目的地址
    s.source_files:需要包含的源文件
    s.resources: 资源文件
    s.requires_arc: 是否支持ARC
    s.dependency:依赖库,不能依赖未发布的库
    s.dependency:依赖库,如有多个可以这样写

    (注: 也有这样写: s.license= { :type => "MIT", :file => "LICENSE" }


    7, 创建tag,并推送到github,依次执行以下命令:

    $ git add .
    $ git commit -m "0.0.1"
    $ git tag 0.0.1
    $ git push --tags
    $ git push origin master

    (注: 当执行完 git push --tags  后终端会让你输入GitHub的账号和密码)

    Username for 'https://github.com':
    Password for 'https://ganlinmeng@github.com': 

    8, 验证podspec文件

    $ pod spec lint Redirect.podspec

    如果终端提示 (but you can use `--allow-warnings` to ignore them).

    你可以

    $ pod spec lint Redirect.podspec --allow-warnings
    • 如果验证不通过,会有详细的ERROR和WARING提示,根据提示依次解决,然后回到第7步重新来一遍。
      注意:在重新开始之前,我们要删除远程库的tag和本地的tag,命令如下:
    $ git tag -d 1.2                   //删除本地tag
    $ git push origin :refs/tags/1.2  // 删除远程库tag

    如果验证通过会这样显示

    9, 如果是第一次提交,需要先执行这个命令:

    $ pod trunk register 这里写邮箱 '这里起个名字' --description=' 这里写描述'

    执行完成之后,会给你的邮箱里发一封邮件,去邮箱点击链接!

    然后提交到CocoaPods

    (注意:由于我验证podspec文件时使用了--allow-warnings 所以这里后面也加上--allow-warnings)

    pod trunk push Redirect.podspec --allow-warnings

    10, 提交完成后,就可以通过cocopods查找Redirect了

    (注意:)刚提交后项目用pod search命令会搜不到,因为本地的索引没有更新,使用下面命令删除索引文件

    rm ~/Library/Caches/CocoaPods/search_index.json

    最后pod search 命令搜到自己的项目,大功告成

     如果还是不行就再执行

    rm ~/Library/Caches/CocoaPods/search_index.json
    pod setup

    再进行pod search,

    -完美

    这样就可以进行使用了.

    cocoaChina也有我的链接贴一下

    http://www.cocoachina.com/ios/20180112/21842.html

    最后感谢各位大佬

    参考:

    https://www.jianshu.com/p/0e1d796b2a42

    https://www.jianshu.com/p/a1339d45a324

    http://www.cocoachina.com/ios/20160301/15459.html

    https://www.cnblogs.com/richard-youth/p/4704413.html

    https://www.jianshu.com/p/283584683b0b

    https://www.cnblogs.com/xzjxylophone/p/4956469.html

     https://www.jianshu.com/p/b5e5cd053464

  • 相关阅读:
    表的简单增删改查
    数据库基础入门语句
    exports与module.exports的区别
    Spring入门——简介
    Mybatis之动态SQL揭秘
    Mybatis的核心组成部分-SQL映射文件揭秘
    Mybatis框架简介、搭建及核心元素揭秘
    实战讲解:SSM+Maven开发APP信息管理平台-developer版
    OpenCV结构简介
    在Linux服务器上安装lxml
  • 原文地址:https://www.cnblogs.com/ljcgood66/p/8269589.html
Copyright © 2011-2022 走看看