can't load gem in macruby
Frage
I just started using MacRuby for a simple Mac Application, and I now have a problem.
For my project I use the rmagick gem.
I installed it as described with the command
sudo macgem install rmagick
Everything worked well, but the problem is that if I try to load it in my AppDelegate.rb file with require 'rmagick'
. I get an error saying that there is no such file to load.
This is strange, because I noticed that if I first build the project normally and then build the deployment target, I'm able to execute the application without any problems.
It would be really cool if there would be a way to use the gem in the development target, because otherwise I need 30 seconds after each change I made which in total is really much xD
Lösung
Yeah RMagick can be a tricky one:
require 'rubygems'
require 'RMagick'
is the answer. Also macruby apparently still requires the require 'rubygems'
. But beware, the module you actually will be using is called Magick
.
A short example:
require 'rubygems'
require 'RMagick'
image = Magick::Image.new "path/to/image.png"
Here you will find the RMagick-documentation.