美文网首页组件化
cocoapod创建私有 pods 遇到的问题

cocoapod创建私有 pods 遇到的问题

作者: Yang152412 | 来源:发表于2016-12-21 23:51 被阅读1177次

    参考文档:
    1、https://guides.cocoapods.org/making/private-cocoapods
    2、https://guides.cocoapods.org/making/getting-setup-with-trunk.html
    3、http://www.cocoachina.com/ios/20150228/11206.html
    4、http://www.jianshu.com/p/95cee84240a8
    5、http://www.jianshu.com/p/815fc21b9d0d
    6、http://www.jianshu.com/p/4b63dfbd8be7

    报错信息
    4、http://www.veryitman.com/2016/11/01/Cocoapods-管理开源项目.html
    5、https://github.com/CocoaPods/CocoaPods/issues/5320
    6、http://www.itdadao.com/articles/c15a597735p0.html [CocoaPod]基于私有仓库的pod创建问题
    7、https://github.com/CocoaPods/CocoaPods/issues/4887

    一、REPO
    用于存放 spec 的仓库。可以参考官方文档:https://guides.cocoapods.org/making/private-cocoapods

    1、创建 Repo

    $ pod repo add REPO_NAME SOURCE_URL
    
    $ pod repo push REPO_NAME SPEC_NAME.podspec
    

    2、删除 REPO

    pod repo remove [name]
    

    二、创建 仓库 Spec。
    1、

    pod lib create SPEC_NAME
    例如:
    pod lib create 
    DDJSON.podspec
    

    2、修改 *****.podspec

    #
    # Be sure to run `pod lib lint DDJSON.podspec' to ensure this is a
    # valid spec before submitting.
    #
    # Any lines starting with a 
    # are optional, but their use is encouraged
    # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
    #
    
    Pod::Spec.new do |s|
      s.name             = 'DDJSON'  
      s.version          = '0.1.0'
      s.summary          = 'DDJSON.'
    # 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/<GITHUB_USERNAME>/DDJSON'  
    # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
      s.license          = { :type => 'MIT', :file => 'LICENSE' }
      s.author           = { ‘***' => ‘*****@***.com' }
      s.source           = { :git => 'https://github.com/<GITHUB_USERNAME>/DDJSON.git', :tag => s.version.to_s }
      # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
      s.ios.deployment_target = '7.0'
    
    # 重点要修改,默认的 s.source_files = 'DDJSON/**/*’,会报 “undefined method `path' for nil:NilClass
    ”错误。
      s.source_files = 'DDJSON/**/*.{c,h,hh,m,mm}'s.public_header_files = 'DDJSON/**/*.h'
      # s.resource_bundles = {
      #   'DDJSON' => ['DDJSON/Assets/*.png']
      #  数据库文件必须要加载 resource 里面,否则 pod install 不会加载到。
      'DDUserTracking' => ['DDUserTracking/*.{xcdatamodeld,xcdatamodel}'] 
      # }
    
      # s.frameworks = 'UIKit', 'MapKit'
      # CoreData 必须添加引用。
      s.frameworks = 'Foundation', 'CoreData','UIKit'
      # s.dependency 'AFNetworking', '~> 2.3'end
    

    3、验证

    pod lib lint
    

    遇到的问题:
    1)“- ERROR | [iOS] unknown: Encountered an unknown error (undefined method `path' for nil:NilClass) during validation.”

    参考:https://github.com/CocoaPods/CocoaPods/issues/4887
    需要把
    s.source_files = 'Pod/Classes/**/*’ 改为 s.source_files = 'Pod/Classes/**/*.{c,h,hh,m,mm}'

    IMO this is a configuration error, although we should handle it more gracefully. It's a configuration error because we're saying that a resource is a source file, which it's not. The easy fix here is to change s.source_files = 'Pod/Classes//'
    to be something like s.source_files = 'Pod/Classes/
    /.{c,h,hh,m,mm}'.

    2)``“Encountered an unknown error (Simulator iPhone 4s is not available.) during validation.”``
    
        升级 cocoapods,“sudo gem install -n /usr/local/bin cocoapods”
    

    4、发布

    # 发布到 github。
    
    $ pod trunk register orta@cocoapods.org 'Orta Therox' --description='macbook air’
    
    # 发布到私有库
    
    pod repo push REPO [NAME.podspec].
    
    # Adding other people as contributors
    
    $ pod trunk add-owner ARAnalytics kyle@cocoapods.org
    

    5、私有库 中 引用私有库

    即在Podspec
    文件中依赖(dependency)私有库
    这种情况就比较麻烦一点,因为毕竟Podspec
    文件中并没有指明私有仓库地址的地方。那么肯定就不在Podspec
    文件里面指明私有仓库的地方。而是在验证和上传私有库的时候进行指明。即在下面这两条命令中进行指明:

    pod lib lint 项目名.podspec --sources=https://github.com/CocoaPods/Specs.git,192.168.0.100:Plutoy/Specs.git
    
    pod repo push REPO --source=https://github.com/CocoaPods/Specs.git,192.168.0.100:Plutoy/Specs.git 项目名.podspec
    

    要不然你在检验项目以及提交项目过程中就会出现Error的情况。
    但是这两种情况还是有点不同的,第一种情况是可以采用开发者模式,而第二种情况不能采用开发者模式,只能通过打tag之后才能进行使用,所以在使用第二种情况下最好是测试好之后打完tag再进行引用。

    6、删除某一个 podspec
    只需要到私有REPO 目录下删除 podspec 即可

    cd ~/.cocoapods/repos/DDSpecs
    rm -Rf PodTestLibrary
    
    # 任何推送到远端
    
    git add —all .
    git ci -m 
    "remove unuseful pods"
    
    git push origin master
    
    

    相关文章

      网友评论

        本文标题:cocoapod创建私有 pods 遇到的问题

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