New in RubyMotion: Versioning, Bundler, Run on Device, Device Console, Better iOS 7 Support
RubyMotion 2.7 is now available, featuring a lot of changes. Let’s go with the major ones.
RubyMotion now offers a way to let you save older versions of RubyMotion on your computer. Older versions of RubyMotion can be used on a per-app basis. This can be useful when you want one of your apps to target a specific version of RubyMotion, because it hasn’t been well tested with newer versions or because of a known issue in newer builds.
To save an older version of RubyMotion, you can pass the —cache-version flag to the motion update command.
As an example, let’s say we have an app that must target RubyMotion 2.6. First, we retrieve that specific version of RubyMotion.
$ sudo motion update --cache-version=2.6 Connecting to the server... Downloading software update... ######################################################################## 100.0% Saving current RubyMotion version... Installing software update... Restoring current RubyMotion version... RubyMotion 2.6 installed as /Library/RubyMotion2.6. To use it in a project, edit the Rakefile to point to /Library/RubyMotion2.6/lib instead of /Library/RubyMotion/lib.
As you can see, we now have RubyMotion 2.6 in /Library/RubyMotion2.6. We can now edit the Rakefile of our app to point to that version. You should see the following line at the top of the file.
We can change it to the following, and we are done.
When you no longer need to keep RubyMotion 2.6 around, you can simply delete the /Library/RubyMotion2.6 directory.
New iOS and OS X RubyMotion projects now automatically integrate with Bundler, which had not been the case before. Projects will now include a Gemfile that you can edit to add your dependencies, and the Rakefile will require and initialize Bundler.
After running a quick poll on Twitter we realized that the vast majority of our users wanted this integration. For those who are not using Bundler, don’t worry, new projects will keep working as before if you do not have the Bundler gem installed in your Ruby distribution.
Run on Device
The rake device task has been improved to run the application as soon as it is installed. Logs printed by the app (using the NSLog function) will also appear in the terminal.
$ rake device Deploy ./build/iPhoneOS-7.0-Development/Timer.ipa *** Application is running on the device, use ^C to quit. Aug 26 15:27:36 lrzs-iPhone Timer
: user clicked start Aug 26 15:27:38 lrzs-iPhone Timer : user clicked stop [...]
The app will quit as soon as you press ^C.
In case you do not want to run the app after installation, you can set the install_only option to any value.
$ rake device install_only=1
Before this change the only way to run the app on the device was to attach a debugger (passing the debug=1 option), which wasn’t a great user experience.
The motion device:console command has been added, which will open the logs on the USB-connected device and print them in real-time.
All messages from the device will be printed, including those from other apps or the system itself. This command can be useful when investigating an environmental issue with your application, as you get to see what’s happening on the device.
Better iOS 7 Support
RubyMotion 2.7 comes with better support for iOS 7. First, we synchronized the toolchain with the latest Xcode 5 and iOS 7 beta builds.
The mouse-over functionality in the REPL that lets you select views has been implemented in the Retina simulator, which is the default when targeting iOS 7. Note that it will work only if the simulator has a 50% scale (use command+3 to enable this).
Attaching the LLDB debugger, which is the default and only provided debugger as of Xcode 5, is now working on apps running on the device. The rake device debug=1 task will work as expected on iOS 7 devices, the only exception being that we will attach lldb and not gdb. This feature, while being functional, is still under development as there are some performance issues when communicating with the device debug server.
The build system has been improved to recognize and handle SpriteKit texture atlas files. Please check the relevant documentation in the Apple developer center to know more.
Finally, we changed the compiler to work around a possible regression in the iOS 7 runtime which was appearing when using certain APIs from MapKit.
Interested in giving RubyMotion a try? We offer a 30 days money back guarantee. Download it today!
Follow us on Twitter to stay tuned with everything that is happening in the community.