美文网首页
手把手教你创建远程私有库-下

手把手教你创建远程私有库-下

作者: CloudL | 来源:发表于2018-11-12 18:19 被阅读21次

    第一步:新建一个项目工程模板

    命令行:pod lib create LYTest

    WX20181112-163708@2x.png
    创建完成后的样子 1542011960060.jpg

    第二步:添加代码文件

    1.找到工程模板所在的文件夹下的此目录,并将你的代码拷贝到此处


    WX20181112-170219@2x.png

    2.将Classes文件夹拖拽到LYTest目录下


    WX20181112-171117@2x.png

    3.cd到Podfile文件所在目录,执行:pod install

    WX20181112-170457@2x.png

    第三步:测试代码是否可以运行

    WX20181112-170540@2x.png

    第四部:提交到远程仓库

    1.在代码托管平台上创建一个代码仓库,将我们的模板工程上传到仓库,并且打一个tag,后面会用到,这里我已经准备好了,你们可以自行创建
    PS:创建开源协议和忽略配置不用选,创建模板工程的时候已经自动帮我们生成了

    2.配置podspec文件


    WX20181112-180551@2x.png
    #
    # Be sure to run `pod lib lint LYTest.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 https://guides.cocoapods.org/syntax/podspec.html
    #
    
    Pod::Spec.new do |s|
      s.name             = 'LYTest'         #名称
      s.version          = '0.1.0'          #版本号,之前tag打的是多少就填多少
      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://dev.tencent.com/u/CloudL/p/LYTest'     #主页地址
      # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
      s.license          = { :type => 'MIT', :file => 'LICENSE' }          #开源协议
      s.author           = { 'CloudLLL' => 'cloudl@koocan.com' }           #作者信息
      s.source           = { :git => 'git@git.dev.tencent.com:CloudL/LYTest.git', :tag => s.version.to_s }                                                 #代码仓库远程地址及版本
      # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
    
      s.ios.deployment_target = '8.0'               #支持版本
    
      s.source_files = 'LYTest/Classes/**/*'        #代码文件路径
      
      # s.resource_bundles = {
      #   'LYTest' => ['LYTest/Assets/*.png']
      # }
    
      # s.public_header_files = 'Pod/Classes/**/*.h'
      # s.frameworks = 'UIKit', 'MapKit'
      # s.dependency 'AFNetworking', '~> 2.3'
    end
    

    3.添加podspec到本地索引仓库

    • 1.查看已有索引库 pod repo

    • 2 .提交podspec到本地索引仓库 pod repo push 索引库 文件名
      PS:提交过程中可能会让你输入之前配置的远程索引仓库的公钥密码

    第五部:测试使用

    1.新建一个iOS工程并创建好Podfile文件
    2.配置Podfile文件


    WX20181112-181546@2x.png

    3.执行pod install

    WX20181112-181651@2x.png

    4.测试使用


    WX20181112-181815@2x.png

    相关文章

      网友评论

          本文标题:手把手教你创建远程私有库-下

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