zoukankan      html  css  js  c++  java
  • iOS 使用CocoaPods管理私有库的公共组件

    最近要使用私有公共组件,故,有了如下的故事。

    参考地址: http://www.cocoachina.com/ios/20150228/11206.html 

    本文使用 https://coding.net 作为Git私有库地址。步骤如下:

    1. 创建一个私有的Git 仓库。(例如:SKPodsStart,创建后地址:https://git.coding.net/LeouCC/SKPodsStart.git

    2. 添加一个私有Spec Repo到本地,终端命令如下:pod repo add [SpecRepoName] [GitAddress]。(例如:

    pod repo add SKPodsStart https://git.coding.net/LeouCC/SKPodsStart.git

    执行成功之后,前往:~/.cocoapods/repos 可以查看你创建的本地Spec Repo。

    当然我的出错了:

    $ pod repo add SKPodsStart https://git.coding.net/LeouCC/SKPodsStart.git

    Cloning spec repo `SKPodsStart` from `https://git.coding.net/LeouCC/SKPodsStart.git` [!] /usr/bin/git clone https://git.coding.net/LeouCC/SKPodsStart.git SKPodsStart Cloning into 'SKPodsStart'... remote: Coding.net Tips : [You have no permission to access this repo.] fatal: unable to access 'https://git.coding.net/LeouCC/SKPodsStart.git/': The requested URL returned error: 403

    说明我没有远程仓库的权限,需要配置SSH KEY,我这里配置一下。(多个coding账号配置SSH KEY,可以指定到某个文件,命令如下

    ssh-keygen -t rsa -f ~/.ssh/id_rsa.coding7834 -C "XXXXX@qq.com" 这里我指定的文件就是coding7834。查看命令:~/.ssh

    然后去coding.net配置,完成。重新添加一个私有Spec Repo到本地。

    3. 新创建一个项目工程文件。

    命令:pod lib create 私有库.podspec文件名   

    例如:pod lib create Posd

    (如果已有项目工程,此步跳过)。此处会有几个问题,如实回答就好了。但是回答完问题会执行pod install命令,这个命令有可能需要翻墙。

    添加/修改一个文件试试。添加修改文件之后,要执行

    pod update

    4. 提交并推送到git仓库。我们创建的私有库有文件,需要更新一下。

    首先添加一个origin remote:
    git remote add origin https://git.coding.net/LeouCC/SKPodsStart.git
    然后更新一下项目:
    git pull origin master
    添加:
    git add .
    提交:
    git commit -m "Add all"
    推送到远程仓库:
    git push -u origin master
    
    添加一个版本Tag:
    git tag 1.0.0
    推送Tag:
    git push --tags

    5. 修改.podspec文件,并用pod lib lint验证有效性。(执行结果出现  PodTestLibrary passed validation. 为有效,否则按照错误提示修改。)。

    6. 提交到私有库。

    命令:pod repo push SpecRepoName .podspec文件名。

    7. 在其他项目中使用私有库。此处有别于公共库,我们是私有库,要指定具体地址。

    source 'https://git.coding.net/LeouCC/SKPodsStart.git'  
    
    source 'https://github.com/CocoaPods/Specs.git'  
    
     
    platform :ios, "7.0"  
    
     
    target "DF" do  
    
    pod 'Posd','~>1.0.0'
    
    pod 'AFNetworking'
    
    end

    过程中可能遇到一些问题,但是,这些问题都不是问题,解决了就好了。 

    好了,恭喜你,你也成功了。

  • 相关阅读:
    超简单本地mock假数据测试,模拟后台数据返回必杀技
    /usr/local/lib/ruby/gems/2.4.0/gems/cocoapods-1.5.3/lib/cocoapods/command.rb:118:in `git_version': Failed to extract git version from `git --version`
    从小白到大神程序员必读15本经典电子书免费送第三季(先到先得)
    从小白到大神程序员必读15本经典电子书免费送第二季(先到先得)
    小白到大神程序员必读15本经典电子书免费送第一季(先到先得)
    在ios Xcode10下小白都能解决library not found for -libstdc++.6.0.9
    52个有效方法(8)
    52个有效方法(7)
    52个有效方法(6)
    52个有效方法(5)
  • 原文地址:https://www.cnblogs.com/wly314/p/5129708.html
Copyright © 2011-2022 走看看