How to make xcode use the correct version of ruby when running a script?
ruby, rvm, xcode
Solution
I used this to run Xcode with an interpreter other than the default system interpreter:
- Quit Xcode if it's open and go to your terminal.
- Activate the rvm you want to use. `rvm use 2.0.0p0`
- Then open Xcode from the terminal: `open -a Xcode`
To test this, you can include something in your build that logs the interpreter's version, or available gems.
Problem
In xcode I have a 'run script' build phase that runs a ruby script. However, it seems that xcode is trying to run it using the default mac 1.8 version of ruby rather than the latest version. Given that the script requires a gem, it's failing with a require error and the path in the error points to `/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/` Obviously the 1.8 in that path is making me suspicious. If I open up terminal and run the command `ruby -v` then it correctly returns `2.0.0p0` which I installed and set as default using RVM. How might I get Xcode to look in the right place? Or am I mis-interpreting this error? Update: To give a little more info, here is the exact error that the compiler is throwing: ``` /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- json (LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require' from /Volumes/Macintosh HD/Documents/Projects/WesternMusicElements/WesternMusicElements/Ruby/NoteCollectionParser.rb:9 Command /bin/sh failed with exit code 1 ```