RubyMotion high above the earth

image

We at InfiniteRed created this cool interactive seven-foot globe for a client. It is entirely written in RubyMotion and uses SceneKit (which is similar to SpriteKit, but for 3D). Check it out.

Also high above the earth, Mark Rickert released his app Dropzones in free-fall at 10,500 feet

Note: he gets 1x cell service (which is the slowest data service available) up to about 11,500ft.

Watch the video here.

image

Dropzones app:

image


If you missed the last issue, you can find it here: issue #52.

Happy coding, Todd Werth (@twerth)

Articles, News, New Gems, and Blog Posts


February 5th, 2015 | blog post | by Paul Sturgess
Tweeting a Screenshot in RubyMotion With UIActivityViewController

February 5th, 2015 | blog post | by RubyMotion
RubyMotion Success Story: QuickLens

February 5th, 2015 | new gem | by Jim Nanney
motion_slick – Motion SlicK RubyMotion DSL and helpers for SpriteKitAction and SpriteKitNode

February 5th, 2015 | new gem | by Hwee-Boon Yar
purplish-layout – a RubyMotion wrapper for Auto Layout on iOS and OS X

February 3th, 2015 | screencast | by Jack Watson-Hamblin
MotionInMotion – Episode 66 – ProMotion, MotionKit, and Sugarcube: Part 1

February 19th, 2015 | blog post | by Ken Miller
CDQ – New-Threading-and-Context-Stack-model

February 17th, 2015 | blog post | by Paul Sturgess
How You Can Use Core Data to Make Your RubyMotion App Faster

February 17th, 2015 | screencast | by Jack Watson-Hamblin
MotionInMotion – Episode 68 – AVFoundation Intro (part 1)

February 17th, 2015 | blog post | by Mark Rickert
Opening a Modal View Controller From a UITabBarController

February 17th, 2015 | screencast | by Jack Watson-Hamblin
MotionInMotion – Episode 68 – AVFoundation Intro (part 1)

February 15th, 2015 | blog post | by Will Raxworthy
An interactive seven-foot globe created entirely in RubyMotion and SceneKit

February 13th, 2015 | blog post | by Paul Sturgess
Using Reveal App to Build a RubyMotion Football Manager Game

February 12th, 2015 | blog post | by Jamon Holmgren
In-app purchases in RubyMotion

February 10th, 2015 | screencast | by Jack Watson-Hamblin
MotionInMotion – Episode 67 – ProMotion, MotionKit, and Sugarcube: Part 2

February 10th, 2015 | blog post | by Jamon Holmgren
Inspect UIWebView with Safari

January 30th, 2015 | blog post | by Jamon Holmgren
What the hex?

January 26th, 2015 | screencast | by Jack Watson-Hamblin
MotionInMotion – Episode 65 – State of RubyMotion Gems

January 26th, 2015 | new gem | by Caram Dache
motion-localize – A RubyMotion plugin to provide localization commands for projects.

January 24th, 2015 | new gem | by Brian Egan
ion_in_motion – Easy use of IonIcons in RubyMotion

January 24th, 2015 | new gem | by Kieran Andrews
volley_motion – A gem to add the Volley Library to your RubyMotion Android Project.

January 22th, 2015 | new gem | by RubyMotion
motion-maven – Integrate 3rd-party Java dependencies in RubyMotion for Android projects using Maven

January 18th, 2015 | new gem | by Mathew Sinclair
restikle – Easily work with Rails routes and schemas in an iOS RestKit+CDQ project.

RubyMotion News


RubyMotion 3.6 released

  • [iOS] Added support for iOS 8.3. Xcode 6.3 beta is required.
  • [iOS, OSX] Fixed a bug where the build would fail when using Xcode 5.
  • [iOS] Fixed a bug where WatchKit applications could not be launched with Xcode 6.2 beta 5.
  • [iOS] Fixed a bug where device log wouldn’t be displayed with rake device if CFBundleName property was changed.
  • [Android] Improved the build time of projects, by not compiling the internal bitcode of Ruby files that have not changed.
  • [Android] Added Math module.
  • [Android] Added Time#{+, -}.
  • [Android] Added Hash#{default, default=, default_proc, default_proc=}.
  • [Android] Added String#{[]=, slice!, chop, chop!, chomp, chomp!, sub, sub!, gsub, gsub!, split}.
  • [Android] Improved Float#to_s, String#[], Array#{[]=, values_at} for CRuby compatibility.
  • [Android] Improved Hash#{shift, replace} for CRuby compatibility.
  • [Android] Fixed a build error in a Bundler environment.
  • [Android] Fixed a bug where Array#[] would crash when returning a large array.
  • [Android] Fixed a bug where Array#delete would crash when removing a lot of elements.
  • [Android] Fixed a bug where Array#[start, length]= would crash when providing a large start position.
  • [Android] Fixed a bug where Array#pop(number) would crash when specifying a large number.
  • [Android] Fixed a bug where Array#flatten would crash when used on a large array.
  • [Android] Fixed a bug where String#scan would crash if many elements would be matched.
  • [Android] Fixed a bug where String#scan returned the wrong value if the Regexp group would be passed as argument.
  • [Android] Fixed a bug where attempting to retrieve a Java field on an inner Java class would always return null/zero on Android 21 / ART, apparently due to a JNI regression (we added a workaround).

RubyMotion 3.5 released

  • [iOS, OSX] Fixed a regression introduced by the previous release where the REPL would not work.

RubyMotion 3.4 released

  • [iOS] Fixed a bug where iOS 8 extensions and their host app could not have different deployment_target values.
  • [iOS] Fixed a bug where an incorrect architecture would be chosen when debugging on a device. Now defaults to the device architecture.
  • [iOS, OSX] Fixed a bug where small structure types couldn’t be returned from Objective-C methods in 64-bit.
  • [Android] Added Bundler support to the project template.
  • [Android] Added the app.theme Rakefile variable to set up the theme of the app. The default value is Theme.Holo.
  • [Android] Added Array#{flatten, flatten!, slice, slice!}.
  • [Android] Added Enumerable#{reverse_each, each_with_object, each_entry, each_slice, each_cons, collect, map, count, find, detect, grep, find_index, flat_map, collect_concat, partition, group_by, first, all?, any?, one?, none?, min, max, minmax, min_by, max_by, minmax_by, member?, include?}.
  • [Android] Improved Array#[] for CRuby compatibility.
  • [Android] Disabled internal/debug VM logs since they impact launch time and general performance. If you want to set them back on (for debugging), the app.vm_debug_logs variable can be set to true.
  • [Android] Fixed a bug where Fixnum#* would cause a runtime crash if the receiver was zero.
  • [Android] Fixed a bug where an ensure statement would cause the project to fail to build, due to a linking error.
  • [Android] Fixed a bug in the Java method dispatcher where it would fail to call methods returning arrays of non-object types (ex. the getBytes method of java.lang.String).
  • [Android] Fixed a bug where trying to set/assign a value to a Java object field would cause a NoMethodError.
  • [Android] Fixed Enumerable#{each_with_index, select} to return an Enumerator when if no block is given.
  • [Android] Fixed a bug where Enumerable methods would be taken in priority over Hash methods (ex. select), due to the fact that the module was included in the wrong class.
  • [Android] Fixed a bug where the use of the break keyword inside a block would cause a compilation crash.
  • [Android] Fixed a bug in the spec framework where the main_activity helper method would only work as expected in the first spec file, and return nil in other spec files.

sudo motion update

Android tip of the week by Darin Wilson


Most of the example code that’s available for Android uses XML files for creating the UI. But fear not, Rubyists: it’s also possible to create UIs programmatically (see the RubyMotion sample repo for some examples).

For the most part, the XML attributes on the UI widgets map directly to similar or identical method calls:

<TextView 
  ...
  android:text="Hello" 
  android:textColor="#FF0000" 
  ...  />
text_view = Android::Widget::TextView.new(self)
text_view.text = "Hello"
text_view.textColor = Android::Graphics::Color::RED

But unfortunately, that’s not always the case:

text_view.layout_marginLeft = 50 # <= raises "undefined method `layout_marginLeft='"

(side note: I’m leaving out the conversion to density-independent values for clarity)

Fortunately, it is possible to set margins programmatically, but the solution is not exactly intuitive:

layout_params = Android::Widget::FrameLayout::LayoutParams.new(
  Android::Widget::FrameLayout::LayoutParams::WRAP_CONTENT,
  Android::Widget::FrameLayout::LayoutParams::WRAP_CONTENT
)
layout_params.setMargins(50, 0, 0, 0)
text_view.setLayoutParams(layout_params)

That’s a painfully verbose constructor just to set a margin, and this approach is further complicated by the fact that you have to make sure you’re using the right LayoutParams class, which can vary depending on the widget or layout that you’re using.

A simpler solution is to get the LayoutParams object directly from the widget itself, but this will only work if you’ve already added the widget to its container:

content_view = Android::Widget::FrameLayout.new(self)
content_view.addView(text_view)
layout_params = text_view.layoutParams
layout_params.setMargins(50, 0, 0, 0)

Having fun yet?

If nothing else, this example shows how badly we need some of the higher-level APIs that have been developed for iOS over the past few years. Android support is still very new, so we have a lot of catching up to do. In the meantime, keep your fingers nice and limber – they’re going to need to do a lot more typing.

Sponsor


My company InfiniteRed sponsors this newsletter by allowing me the time to work on it every week and hosting everything.

Contact us if you ever need help working on a project, mentoring, or other development services . We specialize in RubyMotion and have an awesome team.

image

One more thing


In the future, we may possibly have a UIKit for OS X. It’s called UXKit

Blog post about UXKit

RubyMotion repo using UXKit

Note: I’ve read some reports that this may never be available to the public. I personally think it will, but we will see.


If you have any tips, blog posts, or comments, please send emails to todd@infinitered.com