Make sure the following prerequisites are met:
- RubyMotion is purchased and installed. RubyMotion 2.x is required to create OS X applications.
- Xcode is downloaded and installed.
- Ruby SDK version 1.9 is required.
You can also take a look on RubyMotion samples.
1. Creating a New RubyMotion App
Creating a new RubyMotion app is as simple as creating any other app. Go to File | New Project and choose RubyMotion Application:
Choose an appropriate Ruby SDK and template, for example iOS:
RubyMotion application will be automatically created with the file structure needed:
2. Running Your App
When creating a new RubyMotion app RubyMine also creates default run/debug rake configurations (Run | Edit Configurations...) for you to run the app and tests:
In case of the iOS application you need just to run 'simulator' configuration with Run | Run... command to build your app and run it with the iOS simulator:
To run OS X application, use 'run' configuration that is created automatically instead of the 'simulator'.
3. Working in Code Editor
Working with RubyMotion code you can use code completion for Ruby code as well as for Objective-C code:
All the quick-fixes are also available:
Let's add some code and rerun:
4. Working in Console
With RubyMotion there is no need to rerun your app any time you want to change some code. You can use console for that. First of all point out to the screen element you want to play with. Use Cmd + Mouse, the red border shows the element focused:
Now you can change a color for the label text for example:
And see the changes immediately:
5. Testing Your App
To run spec tests for your app run 'spec' configuration with Run | Run... command. Tests wil be run and the results will be shown in the UI:
6. Debugging Your App
RubyMine also allows debugging a RubyMotion app with a graphical UI. Set a breakpoint with Run | Toggle Line Breakpoint and run 'simulator' configuration with Run | Debug... command. Execution stops at breakpoint so you can analyze variables and run your code step by step:
If you prefer working with LLDB commands use the special LLDB tab:
7. Working on Device
RubyMine provides the ability to run, test and debug applications on the device if you are a registered Apple Developer. Read more on how to create a Developer account.
Add the *.mobileprovision file to the application root folder and change the Rakefile accordingly:
Now you can deploy the application to your device. Make sure the device is plugged and run 'device' rake task (Tools | Run Rake task...):
After deploying to the device, you can run 'device' configuration in the debug mode with Run | Debug... menu and the debugger will stop on the breakpoints when working with the app on the device:
You can also run your spec tests on the device with the 'spec:device' rake task.