Installing CocoaPods With Rbenv

Installing CocoaPods With Rbenv

come from:http://www.egeek.me/2012/07/28/installing-cocoapods-with-rbenv/

2012-07-28 | comments

Usually, each and every iOS project I’ve been working on uses different open-source libraries and frameworks, such as MKStoreKit, JSONKit, CocoaLumberjack, to reuse existing, mostly high-quality, code. Adding them to your Xcode projects brings a question of updating them once in a while. What’s a solution?

The vast majority of the libraries use git as an SCM and are hosted on github. Unfortunately, I had to use corporate subversion for my projects. To relieve the pain, locally every project is also controlled with git. In this scheme, the only solution I saw was to copy the libraries’ sources right in the project’s directory, which has some drawbacks: you can’t easily update them, and unintentionally someone may change the source code, resulting in some complications during updates later.

If the projects used only git, I could add the libraries as submodules. However, these subprojects would contain the whole structure of the project (with demos, tests, etc.). I could add only the required files to the project. But what’s the point of keeping all the rest files?

And then I came across the CocoaPods project, “an Objective-C library manager”. Looks nice. Why not try it?

The text above was a little long prelude to the way I installed CocoaPods on Mac. The article will be interesting to developers who have no idea what to do with Ruby and its environment, such as me. I had no previous experience with Ruby, except for octopress.

First of all, reading the installation instructions here and here suggests that I need to install cocoapods gem (a package in ruby), having updated all the other system gems. But I didn’t feel like messing with system gems in /Library/Ruby/Gems/1.8 directory, that’s why the first command failed:

1
2
3
4
$ gem install cocoapods

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.

Almost grasped the need of the procedure, I bumped into this article, where it’s recommended to use RVM. At this point, I recollected that there are RVM and rbenv tools that manage different ruby installations on the same host. Which one to choose? According to the README, rbenv is unobtrusive and simple, and newer than rvm. Ding, we’ll use it.

Install it with:

1
$ brew update --rebase && brew install rbenv ruby-build

A minute, and it’s here. Then I add the if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi line to my ~/.zshrc, and source it. Next step is to install a newer local version of Ruby: rbenv install 1.9.3-p194 (to check available versions, run rbenv install).

To use this version, I ran rbenv global 1.9.3-p194, and rbenv rehash just in case. It didn’t seem to work, because:

1
2
$ ruby --version
ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]

Five minutes of thoughts later I did source ~/.zshrc and it worked! Now we can easily install bundler (I’m not sure if it’s required here, I read somewhere it helps to manage gems) and cocoapods:

1
2
$ gem install -V bundler
$ gem install -V cocoapods

Do rbenv rehash to be sure. It’s installed now, and you can continue with other tutorials.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值