美文网首页
ios cocopods 远程库制作 不采坑

ios cocopods 远程库制作 不采坑

作者: 年轻就要活出样 | 来源:发表于2019-08-09 16:51 被阅读0次

    精华Pod库分享

    1、创建远程pod仓库

    如图按照提示操作

    Snip20190809_1.png
    工程创建之后会在看到README.MD 和 LICENSE 两个文件。如果没有LICENSE文件,我们可以自行create new file命名为LICENSE。自行创建的文件里面是没有内容的,内容如下,把名称换成自己的github账号名称
    Snip20190809_3.png Snip20190809_2.png
    MIT License
    
    Copyright (c) 2019 账号名称
    
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
    
    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
    

    2、制作本地库

    cd  本地仓库路径
    git clone https://github.com/xxx/xxx.git  远程仓库地址
    

    3、创建*.podspec文件

    终端执行 $ pod spec create 名称  如 AFNetworking
    

    4、编辑*.podspec文件

    注意:自建podspec文件中 spec ===> s

    Pod::Spec.new do |s|
    
    
    
      s.name         = "VNHttpRequest"   名称
      s.version      = "0.0.4"                     版本号,
      s.summary      = "AFNetworking fsdoa"   描述
    
      s.description  = <<-DESC
      Net request ,call back data Serialization to CH
                       DESC
    
      s.homepage     = "https://github.com/guohongqi-china/VNHttpRequest"
      s.license      = "MIT"
      s.author             = { "guohongqi-china" => "820003039@qq.com" }
      s.ios.deployment_target = '8.0' # 平台及支持的最低版本
      s.frameworks = "UIKit", "Foundation" # 支持的框架
    
    
      s.source       = { :git => "https://github.com/guohongqi-china/VNHttpRequest.git", :tag => s.version.to_s }
      s.public_header_files = "VNHttpRequest/**/*.{h}"
      s.source_files  = "VNHttpRequest/**/*.{h,m}"  # 你代码的位置, BitautoTech/**/*.{h,m} 表示 ** 文件夹下所有的.h和.m文件
    
    
      s.dependency "AFNetworking", "~> 3.0" # 依赖库
      s.requires_arc = true # 是否启用ARC
    EOS
      s.prefix_header_contents = pch_AF
      s.ios.deployment_target = '8.0'
    
      s.subspec 'FrameWork' do |ss|
        ss.source_files = 'VNHttpRequest/FrameWork/**/*.{h,m}'
        ss.public_header_files = 'VNHttpRequest/FrameWork/**/*.{h}'
        ss.watchos.frameworks = 'MobileCoreServices', 'CoreGraphics'
        ss.ios.frameworks = 'MobileCoreServices', 'CoreGraphics'
        ss.osx.frameworks = 'CoreServices'
      end
    
      # spec.resource  = "icon.png"
      # spec.resources = "Resources/*.png"
      # spec.preserve_paths = "FilesToSave", "MoreFilesToSave"
      # spec.framework  = "SomeFramework"
      # spec.frameworks = "SomeFramework", "AnotherFramework"
      # spec.library   = "iconv"
      # spec.libraries = "iconv", "xml2"
      # spec.requires_arc = true
      # spec.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
      # spec.dependency "JSONKit", "~> 1.4"
    
    end
    

    常见的写法:

    dependency:写法

    s.dependency = 'AFNetworking' , 'SDWebImage'

    source_files: 写法
    • '*'表示匹配所有文件

    • '*.{h,m}' 表示匹配所有以.h和.m结尾的文件

    • '**' 表示匹配所有子目录

    验证 .podspec 文件的格式是否正确,cd 到 *.podspec 文件所在的目录下

     pod lib lint VNHttpRequest.podspec --allow-warnings --verbose
    
    

    验证成功会出现

    VNHttpRequest passed validation.
    

    5、提交文件 给仓库打tag

    注意:tag的版本号,要与.podspec文件中的版本号一致

    git  add .   提交所有更改
    git commit -m '更改内容'
    git push origin  {master}  推送到远程仓库
    # tag标签
    git tag -m 'first release' 0.0.1 
    git push --tags
    

    注意:以上所有终端命令需要在本地仓库路径执行

    6、提交pod

    • 提交pod之前我们要验证是否注册CocoaPods账户信息
    pod trunk me
    
    • 如果未注册
    终端执行:$ pod trunk register 邮箱地址 '用户名' --verbose
    

    这里我们一般使用github邮箱和用户名, 然后在你的邮箱中会收到确认邮件, 在浏览器中点击链接确认即注册成功;

    • 成功之后继续pod trunk me 如下图成功


      Snip20190809_4.png
    • 提交pod
    pod trunk push VNHttpRequest.podspec --allow-warnings --verbose
    

    严禁按照此流程执行,不会出现问题。如果大家不幸采坑,可检查.podspec文件里的格式,大部分坑都是因为.podspec文件导致,如果解决不了可以私聊我。

    • 本地仓库配置

    Snip20190809_5.png Snip20190809_7.png

    集成结果如图

    Snip20190809_8.png

    仓库地址

    VNHttpRequest库地址。

    Snip20190811_1.png

    谢谢

    相关文章

      网友评论

          本文标题:ios cocopods 远程库制作 不采坑

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