5 Easy Steps To Your First RubyCocoa Application: Difference between revisions
Jump to navigation
Jump to search
Line 16: | Line 16: | ||
# ...choose ''Empty File'' and click ''Next''...<br>[[Image:RubyCocoaTutorialStep1CreatingTheProject07.png]] | # ...choose ''Empty File'' and click ''Next''...<br>[[Image:RubyCocoaTutorialStep1CreatingTheProject07.png]] | ||
# ...name it ''rb_main.rb'' and save it to your project...<br>[[Image:RubyCocoaTutorialStep1CreatingTheProject08.png]] | # ...name it ''rb_main.rb'' and save it to your project...<br>[[Image:RubyCocoaTutorialStep1CreatingTheProject08.png]] | ||
# ...now paste <tt>require 'osx/cocoa'<br>def rb_main_init<br>path = OSX::NSBundle.mainBundle.resourcePath.fileSystemRepresentation<br>rbfiles = Dir.entries(path).select {|x|<br>/\.rb\z/ =~ x}<br>rbfiles -= [ File.basename(__FILE__) ]<br>rbfiles.each do |path|<br>require( File.basename(path) )<br>end<br>end<br>if $0 == __FILE__ then<br>rb_main_init<br>OSX.NSApplicationMain(0, nil)<br>end<br>[[Image:RubyCocoaTutorialStep1CreatingTheProject09.png]] | # ...now paste <tt>require 'osx/cocoa'<br>def rb_main_init<br>path = OSX::NSBundle.mainBundle.resourcePath.fileSystemRepresentation<br>rbfiles = Dir.entries(path).select {|x|<br>/\.rb\z/ =~ x}<br>rbfiles -= [ File.basename(__FILE__) ]<br>rbfiles.each do |path|<br>require( File.basename(path) )<br>end<br>end<br>if $0 == __FILE__ then<br>rb_main_init<br>OSX.NSApplicationMain(0, nil)<br>end</tt><br>[[Image:RubyCocoaTutorialStep1CreatingTheProject09.png]] | ||
# ...add to the existing Frameworks...<br>[[Image:RubyCocoaTutorialStep1CreatingTheProject10.png]] | # ...add to the existing Frameworks...<br>[[Image:RubyCocoaTutorialStep1CreatingTheProject10.png]] | ||
# ...the ''RubyCocoa.framework''...<br>[[Image:RubyCocoaTutorialStep1CreatingTheProject11.png]] | # ...the ''RubyCocoa.framework''...<br>[[Image:RubyCocoaTutorialStep1CreatingTheProject11.png]] |
Revision as of 23:30, 14 June 2010
This is my preparation for the Cetik Event 2010. 2009 I promised to hold a lecture about creating an simple RubyCocoa application.
What you need
- Macintosh of your choice
- MacOS X 10.5 oder 10.6 (10.4 users have to install RubyCocoa theirselves)
- XCode 2.4 or higher[1]
- some time
Step 01: Creating the project
- Click Create a new XCode project...
- ...choose Application on the left and Cocoa Application on the right and click Choose......
- ...choose a cosy[2] place and a name for your project, I named it Wikipedia...
- ...this is your newly created project...
- ...edit main.m and paste the following...
#import <RubyCocoa/RBRuntime.h>
int main(int argc, const char* argv[])
{
return RBApplicationMain("rb_main.rb", argc, argv);
} - ...choose File New File......
- ...choose Empty File and click Next...
- ...name it rb_main.rb and save it to your project...
- ...now paste require 'osx/cocoa'
def rb_main_init
path = OSX::NSBundle.mainBundle.resourcePath.fileSystemRepresentation
rbfiles = Dir.entries(path).select {|x|
/\.rb\z/ =~ x}
rbfiles -= [ File.basename(__FILE__) ]
rbfiles.each do |path|
require( File.basename(path) )
end
end
if $0 == __FILE__ then
rb_main_init
OSX.NSApplicationMain(0, nil)
end - ...add to the existing Frameworks...
- ...the RubyCocoa.framework...
- Done! At this time you can already run your application. It will show an empty window, can be quit and even has an about box. Not bad for zero programming. If you're too lazy to do the above steps, you might want to download this.
Step 02: ?
- Links
- Fußnoten: