|
From: Jonathan P. <jp...@dc...> - 2005-05-23 23:55:24
|
On 22 May 2005, at 20:45, Dave Howell wrote: > On May 17, 2005, at 9:10 AM, Jonathan Paisley wrote: > >> On 15 May 2005, at 20:49, Dave Howell wrote: >> >>> I have tried installing RubyCocoa repeatedly, carefully following >>> all the instructions, and scrubbing things out a few times, but >>> nothing I've done has given me a functioning installation. It may >>> not even be RubyCocoa's fault; the error message is so massively >>> cryptic that I can't trace it any farther. >>> >>> /Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/ >>> osx/objc/oc_import.rb:22:in `module_eval': undefined method >>> `NSClassFromString' for OSX:Module (NoMethodError) >>> >>> So, um, I guess that the OSX module getting included in >>> RubyCocoa's not doing its job somehow? This error occurs if the native module hasn't been loaded. Normally, when you run your program from a compiled xcode project, the main application gets linked with the RubyCocoa framework, and it takes care of starting the Cocoa application and initialising the ruby interpreter. As a result, it's not necessary to "require 'rubycocoa'" within the program at any time. On the other hand, if you run your script from the command line, the rubycocoa require is necessary. The osx/*rb code should be handling this automatically, but I think it perhaps isn't at the moment (I haven't investigated this in detail). Try adding: require 'rubycocoa' right at the beginning of rb_main.rb. However, it shouldn't be necessary to do this since the compiled xcode project already references the framework. >>> >>> >>> >ruby -v >>> ruby 1.8.2 (2004-11-03) [powerpc-darwin7.5.0] >> >> Can you post a complete IRB session or script that you're trying? >> >> What version of Mac OS X are you using? >> >> Where did your ruby come from? >> > > I posted a pretty detailed description of the whole thing on > O'Reilly's web site in the discussion area of the "An Introduction > to RubyCocoa, Part 2" article. http://www.macdevcenter.com/pub/a// > mac/2004/10/12/cocoa.html?page=last#thread Look for the thread > entitled "Installer Grief," although I think you can ignore the > first message. A general comment about moving ruby around: it sounds like things got initially got confused because you moved ruby to a different path after installing it. ruby has compile-time paths embedded in it for the standard library. You say that it's stupid to put things in an invisible folder on a mac. I'd argue that this is only the case if the items in question are intended to be used from the GUI. ruby is not. The RubyCocoa applications you may create should be GUI-accessible, but this doesn't mean that ruby itself should be. The proper way to identify which version of ruby you want to use (Apple's on /usr/bin or self-installed in /usr/local/bin) is to update your PATH (using 'setenv' for tcsh or 'export' for bash/zsh). It should never be necessary to modify some Apple-installed system files (like /usr/bin/ruby). > > In a nutshell, I installed RubyCocoa Panther 0.4.1 via CVS, and > got the following during the Make run: > > gcc -fno-common -F../../framework/build -framework RubyCocoa -I. - > I/usr/local/lib/ruby/1.8/powerpc-darwin7.5.0 -I/usr/local/lib/ruby/ > 1.8/powerpc-darwin7.5.0 -I/Users/snarke/Personal/Programming/Ruby/ > rubycocoa-panther/ext/rubycocoa -c -o rubycocoa.o rubycocoa.m > > gcc: -framework: linker input file unused because linking not done > > gcc: RubyCocoa: linker input file unused because linking not done > > Then I built the script presented in the article by following the > instructions *precisely,* but that just gets me the NoMethodError. > I've also tried a completely unrelated Ruby script (somebody else's > example using a variant of CurrencyConverter) and gotten exactly > the same error message (above). How are you running the program? From Xcode or using ruby from the command line? If you have built and are running the native program, please mail the output from running 'otool -L' on the application main program. For example, if your program was called MyProg.app, you'd try something like this: $ otool -L MyProg.app/Contents/MacOS/MyProg (assuming you're in the directory containing MyProg.app) |