博客> CocoPods && Git系列教程之环境搭建
CocoPods && Git系列教程之环境搭建
2020-02-17 19:28 评论:0 阅读:1140 13682527955
cocoapods git

1.检测ruby环境搭建

使用命令:ruby -v

如: $ ruby -v ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]

2.检测ruby的景象路径 使用命令:gem sources -l

如: $ gem sources -l

****CURRENT SOURCES****
https://ruby.taobao.org/

2.1 当ruby gems 的源如果嫌更新慢可以更换国内淘宝的源 终端输入如下命令(把Ruby镜像指向taobao,避免被墙,你懂得) gem sources --remove https://rubygems.org/ gem sources -a https://ruby.taobao.org/

  更换淘宝源如:
   $ gem sources -l
   *** CURRENT SOURCES ***> `1. - list text here`
   https://rubygems.org/

3.下载安装CocoaPods 终端输入:sudo gem install cocoapods

$ sudo gem install cocoapods Fetching: i18n-0.7.0.gem (100%) Successfully installed i18n-0.7.0 Fetching: thread_safe-0.3.5.gem (100%) Successfully installed thread_safe-0.3.5 Fetching: tzinfo-1.2.2.gem (100%) Successfully installed tzinfo-1.2.2 Fetching: minitest-5.8.4.gem (100%) Successfully installed minitest-5.8.4 Fetching: activesupport-4.2.6.gem (100%) Successfully installed activesupport-4.2.6 Fetching: nap-1.1.0.gem (100%) Successfully installed nap-1.1.0 Fetching: fuzzy_match-2.0.4.gem (100%) Successfully installed fuzzy_match-2.0.4 Fetching: cocoapods-core-0.39.0.gem (100%) Successfully installed cocoapods-core-0.39.0 Fetching: claide-0.9.1.gem (100%) Successfully installed claide-0.9.1 ....

4.cd进入.xcodeproj文件所在的目录,通过以下命令来创建一个Podfile $ pod init

如: platform :ios, '7.0'

target "AppName" do

end

添加需要管理的库文件: pod 'X', '~> 1.1'

对于那些不在CocoaPods公共Git仓库中的库,你可以用任何一个Git, Mercurial或者SVN仓库取代,并且还可以指定具体的commit, branch或者tag。 pod 'Y', :git => 'https://xxxx', :commit => 'xxx'

安装: $ pod install

如果只是更新请使用: $ pod update

在安装之前可以使用命令:try是一个及其实用但又鲜为人知的CocoaPods命令,通过它你能够在安装一个库之前,先试用一下。

你只需要在try后面加上任意一个CocoaPods公共库的名称,就能试用它了! $ pod try xxxx

--------------创建一个本地的仓库---------------------------

创建一个本地pod库: pod lib create xxxlib

以下是xxx.podspec Pod::Spec.new do |s| s.name = xxx s.version = xxx s.license = xxx s.summary = xxx s.homepage = xxx s.authors = xxx s.social_media_url = "https://twitter.com/mattt" s.source = { :git => 'https://github.com/xxx', :tag => 'x.x.x' } s.source_files = 'NSHipsterKit' end

pod file 中设置: pod 'xxxllib', :path => '../../xxx/xxxlib'

--------------创建一个本地的仓库---------------------------

淘宝的官方镜像地址: https://ruby.taobao.org

收藏
1
sina weixin mail 回到顶部