Archives: Issues

Issue #56

  • Estimated reading time: 7 minutes, 15 seconds

#inspect 2015 in Paris is almost here

#inspect 2015 is almost here, but there are still tickets left. If you’re in Europe, or want to go to Europe, join us. If you need help with accommodations or anything else I’m sure the community will help out, as they did last year.

image

Last year was awesome: everyone got to meet everyone else, talk programming, have dinner and drinks, and make new friends. Many of us only talk to each other online, so it’s fun to actually meet in person. Plus we learned a lot.

HipByte will be talking about future features of RubyMotion. Amir Rajan will be discussing DarkRoom. Six of us from InfiniteRed will be there. We’ll be talking about RedPotion, BluePotion, and a bunch of other exciting things. Jamon Holmgren, the creator of ProMotion, will also be talking about RedPotion. Will Raxworthy will discuss the globe we created (this will be a cool talk I’m sure)

Lastly, as we’re moving to fewer issues of the Dispatch (every month or so), we’re trying to add more excellent quality content.

Happy coding, Todd Werth (@twerth)


In this issue:

  • Community articles, news, new Gems, and blog posts
  • RubyMotion news
  • Derek’s Apothecary. Learning to cook with RedPotion
  • Pro Tip by Jamon Homlgren New column
  • BluePotion – like RedPotion, but for Android New column
  • Android tip of the week by Darin Wilson
  • App of the Week
  • One more thing

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

Community Articles, New Gems, and Blog Posts

May 6th, 2015 | blog post | by Elliott Draper
Capturing video and audio on Mac OS X with RubyMotion

May 3th, 2015 | new gem | by Steve Kellock
RubyMotion + iOS 7 & up + NSMutableAttributedString

May 29th, 2015 | blog post | by Jamon Holmgren
Speed II

May 21th, 2015 | blog post | by Adam Rubin
Ruby Motion Layout Options

May 15th, 2015 | blog post | by Elliott Draper
Dragging and dropping into your RubyMotion Mac OS X app

May 13th, 2015 | blog post | by RubyMotion
Announcing remaining speakers and schedule of RubyMotion #inspect 2015

May 13th, 2015 | new meetup | by Nick Daniels
London RubyMotion Inaugural Meetup

May 12th, 2015 | blog post | by Paul Sturgess
Core Data in RubyMotion – Defining Your Schema in Code

May 12th, 2015 | blog post | by RubyMotion #inspect
Two days, one track, 100% RubyMotion

May 11th, 2015 | blog post | by Darin Wilson
Learning Android with RubyMotion – Chapter 3

April 30th, 2015 | blog post | by Nicolas Cavigneaux
Downgrading RubyMotion

April 25th, 2015 | new gem | by Austin Seraphin
UIAccessibility wrappers for RubyMotion. Making accessibility accessible.

RubyMotion News

image

RubyMotion 3.12 release

  • [Android] Added support for Android M (experimental). To target it, set app.api_version to MNC.
  • [Android] Improved Object#raise to accept an exception class or instance.
  • [Android, iOS, OSX] Introduced a new experimental file dependency resolver. If you have any file dependency manually specified in the Rakefile, the new resolver should make those unnecessary. To try it, set the environmental variable “experimental_dependency” (e.g. rake experimental_dependency=1). The new resolver will become the default in a future release.
  • [iOS] Fixed “duplicate symbol” error when it would build app for iOS device using Xcode 6.2.
  • [iOS] Fixed a bug where the latest version of the Facebook iOS SDK would not compile correctly.
  • [iOS, OSX] Improved compilation time for projects that have many source files. 2~ times faster.
sudo motion update

Derek’s Apothecary. Learning to cook with RedPotion

image

Using Dispatch::Group to Aggregate Multiple Background Threads

If you need to perform some action after multiple asnychronously running threads have completed, Dispatch::Group may be what you are looking for.

You can assign any number of asynchronous background threads to a Dispatch::Group instance and tell it to halt execution of code until all of the blocks associated with it have finished executing.

In this example, the two dispatches are kicking off HTTP requests to an API server and waiting for the responses. They are both assigned to @group, which is an instance of Dispatch::Group.

@group = Dispatch::Group.new
Dispatch::Queue.concurrent.async(@group) do
  API.get_data do |data|
    @data = data
  end
end
Dispatch::Queue.concurrent.async(@group) do
  API.get_other_data do |other_data|
    @other_data = other_data
  end
end

@group.wait
mp @data
mp @other_data

The app will print out @data and @other_data after both background threads have completed. Nice!

So, if calling wait on a Dispatch::Group brings everything to a grinding halt, what would happen if you were to do the following in a PM::TableScreen?

def update_data
  @group = Dispatch::Group.new
  Dispatch::Queue.concurrent.async(@group) do
    API.get_data do |data|
      build_table_cells(data)
    end
  end
  Dispatch::Queue.concurrent.async(@group) do
    API.get_other_data do |other_data|
      build_table_cells(other_data)
    end
  end
end

def will_appear
  rmq.animations.start_spinner
  update_data
end

def view_did_appear(animated)
  @group.wait
  update_table_data
  rmq.animations.stop_spinner   
end

The spinner would continue to entertain the user with its relentless spinning, but the UI would not respond to user interactions until the table has been reloaded.

Until the next RubyMotion Dispatch, happy coding!

Pro Tip by Jamon Holmgren

image

Tip: Testing ProMotion Screens

ProMotion screens are subclassed UIViewControllers, so the RubyMotion Bacon suite can mount them in the simulator. It does require a small change in how you set up the test, however.

describe HomeScreen do
  tests HomeScreen

  def screen
    @screen ||= HomeScreen.new(nav_bar: true)
  end
  def controller
    screen.navigationController || screen
  end
  after { @screen = nil } # Important!

  it "is a ProMotion screen" do
    screen.should.be.kind_of(PM::Screen)
    controller.should.be.kind_of(UINavigationController)
  end

  it "has been set up" do
    screen.title.should == "Home"
  end

  it "has a button" do
    tap("Press Me")
    view("Pressed").should.not.be.nil
  end
end

BluePotion – like RedPotion, but for Android

image

BluePotion is the Android version of RedPotion. We’re spending a lot of time working on it right now. It’s currently in Alpha.

We are building RMQ Android, ProMotion Android, and BluePotion all at once, and they all are inside BluePotion.

We’re supporting Android XML layouts, using RMQ stylesheets the standard Android way, and eventually an exact copy of RedPotion’s layout system.

Many things work, but there is a lot to do, so use it at your own risk.

To try it out:

gem install bluepotion
bluepotion create myapp
cd myapp
bundle
rake newclear

In your REPL, do this for fun:

rmq.log_tree
find(Potion::View).log
# etc

If you haven’t setup Android yet, read this first: Gant Laborde’s post on Genymotion.

Android tip of the week by Darin Wilson

image

Genymotion is a fantastic replacement for the standard Android emulator. If you’re not already using it, check out Gant Laborde’s post on how to get it up and running.

But as good as it is, it has one annoying behavior which comes up with RubyMotion from time to time: the dreaded Silent Failure. You try to launch your app, and nothing happens, not even an error message. Developers have nightmares about this sort of thing.

One way to root out the problem is to look at the logs, which you can generate by going into Settings -> Misc, but an even quicker way is to drag and drop your app’s .apk file directly onto the Genymotion device, which is located in your project’s build subdirectory. In most cases, this will give you the error message you’re looking for.

App of the Week

image

Purr – Adorable Cat Simulator and Realistic Virtual Pet

Created by Particle Spectrum Labs

“Designed to induce extreme relaxation and overwhelming cuteness, Purr was our solution to our personal cat allergy problems. As avid cat lovers we wanted an app for all cat lovers. An all-around feel good app.

We teamed up with our local animal shelter to film the darling cats seen in this app. In the process we realized we needed to find a way to make a difference. So we decided to donate 50% of all the proceeds from purchases to animal shelters. We intend to rotate which shelters it goes to so that we can help as many felines as possible”

Gems

  • cocoapods
  • motion-cocoapods
  • particle-pack (own wrappers for shop / video / audio functionality)
  • bubble-wrap
  • motion-installr

Pods

  • Parse SDK integration
  • Mixpanel
  • NewRelicAgent

Sponsor

image

My company InfiniteRed sponsors this newsletter, and does a lot of work on various gems for RubyMotion.

We exclusively work in RubyMotion on both iOS and Android for clients all over the world.

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

image

One more thing

image

WWDC 2015

Apple Worldwide Developers Conference. June 8-12, San Francisco.


The RubyMotion Dispatch is edited by Todd Werth and Derek Greenberg.

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

Issue #55

A game-changer! Automatic code reloading in RMQ and RedPotion stylesheets

Jamon Holmgren came up with a very clever way to auto reload stylesheets in the dev environment. He wrote a blog post about it here. He and I then developed it in both RMQ and RedPotion.

Here is a gif of it in action.

image

To try this, updated your RedPotion:

gem update ruby_motion_query redpotion

Then launch your app in the simulator and enter this in the REPL:

rmq_live_stylesheets

Or in RedPotion:

live

There still are some rough edges, but I do NOT want to go back to the way we use to do it. Check it out, it’s really awesome.


New column

We have a new column (see below) in the Dispatch written by Derek Greenberg, “Derek’s Apothecary. Learning to cook with RedPotion”.

In every issue Derek is going to teach you something about RubyMotion and/or RedPotion.


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

Happy coding, Todd Werth (@twerth)

RubyMotion community


Articles, news, new Gems, and blog posts from the RubyMotion community.

April 6th, 2015 | new gem | by RubyMotion
motion-gradle – Integrate 3rd-party Java dependencies in RubyMotion for Android projects using Gradle

April 3th, 2015 | blog post | by Jamon Holmgren
ProMotion 2.3 – Notable Changes

April 22th, 2015 | blog post | by RubyMotion
Announcing new speakers for RubyMotion #inspect 2015

April 18th, 2015 | new gem | by Thomas Broomfield
motion_panel – A native Rubymotion wrapper around the Mixpanel API

April 18th, 2015 | new gem | by Jamon Holmgren
compressor – Concatenates your RubyMotion source files for faster compile times.

April 17th, 2015 | blog post | by Jamon Holmgren
Speeding up RubyMotion compile times by 95%

April 16th, 2015 | new gem | by Darin Wilson
moran – Simple JSON parsing and generation for RubyMotion Android

April 16th, 2015 | blog post | by Gant Laborde
RubyMotion Android in the Emulator with Genymotion

April 15th, 2015 | blog post | by Jamon Holmgren
Live Code Reloading in RedPotion

April 15th, 2015 | blog post | by RubyMotion
New in RubyMotion for Android: Automatic Setup, RubyMine, Intel Architecture, Gradle, Improvements

April 11th, 2015 | new gem | by Gant Laborde
PackingPeanut – App persistent data for RubyMotion Android

April 1th, 2015 | gem. It now works in RubyMotion | by Felix Krause
snapshot – Automate taking localized screenshots of your iOS app on every device

Derek’s Apothecary. Learning to cook with RedPotion


image

New RedPotion documentation

We’ve started to assemble the documentation for RedPotion. You can read it at docs.redpotion.org

In RedPotion, you can use find instead of rmq

You can still use rmq, find is just an alias, but find often describes better what you’re doing:

find(my_view).find(UIButton).hide

Troubleshooting

Corrupt/missing Cocoapods Specs repository?

You run rake pod:install on a freshly createdRedPotion app and it hangs on Updating spec repo master. Presumably, you’ve already run pod setup one time on your machine, so what gives?

If you see an error message about pod not being able to find the master spec repo when you run rake pod:install --verbose, you can perform a clean pod setup:

> pod repo remove master
> pod setup

Now you should be able to run rake pod:install.


Mysterious errors when running rake?

Running rake was working perfectly last night, but this morning, you are getting mysterious errors, such as

Simulator session started with error: Error Domain=NSPOSIXErrorDomain Code=3 "Failed to lookup the process ID of com.your_domain_here.my_awesome_app after successful launch.  Perhaps it crashed after launch."

Your environment might be borked. Try this:

rake newclear

The nuke task performs the following operations:

Cleaning Project...
    Delete ./build
    Delete ./resources/my_awesome_app.momd
    Delete /Users/<your user>/.rvm/gems/ruby-2.1.1/gems/cdq-1.0.2/lib/../vendor/cdq/ext/build-iPhoneSimulator
     Clean ./Pods.xcodeproj for platform `iPhoneSimulator'
     Clean ./Pods.xcodeproj for platform `iPhoneOS'
    Delete vendor/Pods/build-iPhoneSimulator
    Delete /Users/<your user>/Library/RubyMotion/build
    Delete vendor/Pods

Resetting simulator...

Bundling...

Setting up cocoapods...

Installing cocoapod dependencies...

rake

Most of the items (other than rvm gems and /Users/<your user>/Library/RubyMotion/build) that are deleted and cleaned exist within your current project directory. Nuking your project is a benign operation. since running rake rebuilds everything that was nuked, so give it a try.

Android tip of the week by Darin Wilson


image

If you’ve been using motion-maven to manage your 3rd party Java dependencies, you should consider switching to motion-gradle.

Based on the deep integration of Gradle into Android Studio, it appears that Google is throwing all of its mighty weight behind Gradle, so that appears to be where the future lies. Plus, the motion-maven project page now directs you to motion-gradle, so HipByte is apparently throwing its not-quite-as-mighty-as-Google’s weight behind it as well.

Switching to motion-gradle is very straight-forward. The syntax is almost identical, and the package names will be identical in most cases as well.

Another incentive to switch is that motion-gradle can do something that motion-maven can’t: manage Android support libraries:

app.gradle do
 # add the v4 support library
  dependency "com.android.support", artifact: "support-v4", version: "18.0.+"
end

This allow you to put all of your external dependencies into one place, and not have them scattered between app.gradle and app.vendor_project. This should make for a much more readable Rakefile.

Sponsor


image

My company InfiniteRed sponsors this newsletter, and does a lot of work on various gems for RubyMotion.

We exclusively work in RubyMotion on both iOS and Android for clients all over the world.

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

image

RubyMotion News


image

Rubymotion 3.10 Released

  • [Android] Fixed typo in android.rb template which breaks incremental builds. Thanks to Darin Wilson for the patch (pull request #210).
  • [Android] Fixed rake {emulator,device} debug=1 for multi-arch projects.
  • [Android] Added Module#const_get.
  • [Android] Fixed a bug where calling a Java method that returned a large non-Object Java array would crash the runtime by creating a JVM stack overflow.
  • [Android] Fixed a bug when calling the super version of a Java method, where it would fail if the current stack trace included a super Java call of the same method name but of a different class.
  • [Android] Fixed a bug where #initialize methods would not be honored when defined in superclasses.
  • [Android] Fixed a bug where an assertion would happen when trying to resolve a Java class at runtime.
  • [Android] Fixed a bug where a crash would happen when changing the value of a local variable that previously contained a reference to a constant literal (ex. symbol).
  • [iOS] Added support for iOS 8.4 (beta).
  • [iOS] Fixed a wrong in Watch app templete which notification handler should invoke call method for Proc handler object. Thanks to Dave Shapiro for the patch (pull request #207).
  • [iOS] Fixed a bug which it would be trigger a crash when large structures (like CMTime) will be passed into Objective-C methods/funtions on ARM64.
  • [iOS] Fixed a bug which it would be trigger a crash when it will call NSDecimalNumber#decimalValue method on ARM64.
  • [iOS] Fixed a bug which UIInterfaceOrientation would cause link error when specify iOS 8.2 or below as deployment target.
  • [iOS, OSX] Fixed a bug where small structures with only float members could not be passed/returned in a 64-bit environment.

Rubymotion 3.9 Released

  • [Android] Projects now support multiple architectures. The app.arch variable is replaced by app.archs which takes an array of architectures. By default, we still build for arm 32-bit only.
  • [Android] Added x86 (Intel 32-bit) support. This is mainly used to run apps in faster emulators (such as Genymotion). To build for x86, simply edit your project’s Rakefile to add the architecture (app.archs << ‘x86’).
  • [Android] Added the app.optional_features to let users specify optional features in the manifest file.
  • [Android] Make sure all Ruby file paths are flattened into single Array. Thanks to Darin Wilson for the patch (pull request #189).
  • [iOS, OSX] The Ruby runtimes have been rebuilt with Xcode 6.3 final.
  • [iOS] Fixed ARM64 issues introduced since Xcode 6.3 final.
  • [iOS] Fixed a bug where the REPL would crash when using an old simulator.
  • [iOS] Fixed a bug where the value of app.version and app.short_version between the container and watch apps were not synchronized when submitting to iTunes Connect. Thanks to digitalfx for the patch (pull request #205).
  • [iOS] Fixed a bug where watch apps could not be submitted to iTunes Connect.
  • [iOS] Fixed a bug where satch apps would not follow the deployment target of the host app.
  • [iOS] Fixed a bug where rake watch would not launch the watch app when using Xcode 6.3 stable.
  • [iOS] Fixed a bug where dSYM files were embeded even if the app was built with release mode if app has extensions.
  • [OSX] Fixed a bug where app would crash when running tests if the UIDevice class is defined.
  • [iOS, OSX] Fixed a bug where small structures with only float members could not be passed/returned in a 64-bit environment.

Rubymotion 3.8 Released

  • The toolchain has been upgrated to LLVM 3.5.
  • [Android] Added the motion android-setup command which downloads and installs the Android SDK and NDK automatically. Run the `motion android-setup –help’ command for more information.
  • [Android] Added app.support_libraries option in the Rakefile, which is an array containing the names of Android support libraries to be included in your app E.g.:
  app.support_libraries << 'google-play-services'
  app.support_libraries << 'android-support-v4'
  • [Android] Added support for API level 22. Removed support for very old versions of Android that are no longer supported in the SDK.
  • [Android] Added support to generate Ctags file via the rake ctags task.
  • [Android] Fixed a bug where classes.dex would not be re-generated when a resource file was changed. Thanks Eito Katagiri for the patch.
  • [Android] Fixed a bug where running specs would crash.
  • [iOS] Fix a bug where a build error would happen when building a project for ARM 64-bit using Xcode 6.3 Beta.
  • [iOS, OSX] Fixed the build system to not recompile .strings files on every build.
  • [iOS, OSX] Fixed a bug where rake profile could not launch Instruments.app when it will specify Instruments template with Xcode 6.2.
  • [iOS] Fixed a bug where rake background_fetch=true would not work with with Xcode 6.2.
  • [iOS, OSX] Fixed the build system to print a warning if a framework included in the Rakefile does not have a corresponding .bridgesupport file (e.g. it has been mispelled).
  • [iOS, OSX] Fixed the build system to not delete .storyboardc files if the corresponding .storyboard file does not exist.
  • [iOS, OSX] Fixed a rare case where gdb would be used instead of LLDB when running in debug mode.
sudo motion update

Wat


Testing on Android devices is fun:

image

One more thing


image

The Apple Watch is being shipped today to those lucky enough to be in the first shipment. I’ve created a very simple RubyMotion watch app. You have to use IB for your view, but the rest of your code goes into the app running on the phone. It wasn’t terrible difficult.

If you create something for the Apple Watch, no matter how small, let me know and I may put it in the next Dispatch.


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

Issue #54

#inspect 2015 in Paris announced

image

#inspect will be in France this year, in Paris on the 1st and 2nd of July.

You can find more info here. Here is the blog post announcing it.

Many of our team will be there, Jamon Holmgren and I will be giving a presentation about RedPotion (see more about RedPotion below).


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

Happy coding, Todd Werth (@twerth)

Articles, News, New Gems, and Blog Posts


March 26th, 2015 | new gem | by digitalMoksha
linkify-it-rb – Links recognition library used with motion-markdown-it (for Ruby and RubyMotion)

March 26th, 2015 | new gem | by digitalMoksha
mdurl-rb – URL utilities for motion-markdown-it parser, for both Ruby and RubyMotion

March 25th, 2015 | new gem | by digitalMoksha
uc.micro-rb – Micro subset of unicode data files for motion-markdown-it projects (for Ruby and RubyMotion)

March 25th, 2015 | blog post | by Jamon Holmgren
A React.js Pattern for your RubyMotion app

March 19th, 2015 | new gem | by Gant Laborde
RedAlert – iOS Alerts and ActionSheets with ease

March 18th, 2015 | new gem | by Ryan Linton
medic – A RubyMotion wrapper for HealthKit

March 16th, 2015 | new gem | by Brian Pattison
oauth2 – A RubyMotion wrapper for the OAuth 2.0 protocol.

March 16th, 2015 | blog post | by RubyMotion
Announcing RubyMotion #inspect 2015

March 13th, 2015 | blog post | by Austin Seraphin
RubyMotion, the Apple Watch, and Accessibility

March 12th, 2015 | new gem | by Magoosh
motion_record – Miniature ActiveRecord for RubyMotion

March 11th, 2015 | blog post | by RubyMotion
Announcing the RubyMotion Community Forum

March 10th, 2015 | blog post | by RubyMotion
RubyMotion Success Story: Fandor

March 4th, 2015 | new gem | by Caram Dache
PresentationKit for RubyMotion

March 3rd, 2015 | blog post | by Shishir Joshi
Creating custom listviews in Android using RubyMotion

March 3rd, 2015 | new gem | by InfiniteRed, ClearSight, and David Larrabee
redpotion – Combines RMQ, ProMotion, CDQ, AFMotion, MotionPrint and MORE

March 3rd, 2015 | blog post | by Gant Laborde
Introducing RedPotion – Simple, Fast, Ruby Gem for iPhones

March 3rd, 2015 | blog post | by Paul Sturgess
Using PaintCode to Dynamically Create Images in the iOS Football Manager Game Title Challenge

March 1st, 2015 | new gem | by Jamon Holmgren
mem-watcher – Helps you keep an eye on your RubyMotion iOS app’s memory and CPU usage.

February 27th, 2015 | new gem | by Jamon Holmgren
motion-docs – Access RubyMotion documentation from your REPL

February 27th, 2015 | new gem | by digitalMoksha
motion-strscan – Implementation of StringScanner class for RubyMotion

RubyMotion News and Announcements


#inspect 2015 in Paris announced

#inspect will be in France this year, in Paris on the 1st and 2nd of July. Join us.

Announcing the new RubyMotion forums

The community has new forums to discuss RubyMotion thanks to Will Raxworthy who set it up using Discourse. It is much better than Google Groups.

http://community.rubymotion.com

RubyMotion 3.7 released

  • Fixed a bug where the motion command would not work as expected if Ruby was installed with rbenv/RVM.
  • [iOS] Fix a bug where the build system would not detect the properties of the running simulator if it existed with a different version of iOS.
  • [iOS] Fixed a bug where a WatchKit app would not launch on the simulator if it was built with x86_64 (64-bit Intel) only.
  • [iOS, OSX] Improved the symbolication of exception backtraces. Backtraces are now properly symbolicated when running on the device. This is done by parsing the dSYM bundle at runtime. For this to work, in development mode, the dSYM will be embedded within the application bundle. (This is disabled in release mode). You can control this setting with the app.embed_dsym variable in the project’s Rakefile.
  • [iOS, OSX] Improved performance when creating empty Hash objects. ~2 times faster.
  • [iOS, OSX] Improved performance when creating very small Array objects. ~30% faster.
  • [iOS, OSX] Bridgesupport files for vendor projects are now generated in the common build directory (~/Library/Rubymotion/build). This fixes a problem when vendoring the Reveal framework.
  • [iOS, OSX] Added a feature to disable capturing view (command key + moving mouse over) in iOS simulator or OS X app. To enable/disable capturing view, run enable_capture or disable_capture commands in REPL. If you want to disable capturing before the application is launched, you can set the DISABLE_CAPTURE environment variable when you will run the rake command. (ex. $ rake DISABLE_CAPTURE=1).
  • [Android] The runtime is now using the GNU C++ stdlib for better internal support and also upcoming new features.
  • [Android] Improved compilation time, compiling multiple files in parallel.
  • [Android] Support for defining manual file dependencies via app.files_dependencies.
  • [Android] Added Module#module_function.
  • [Android] Added Symbol#to_sym.
  • [Android] Added Time#usec.
  • [Android] Object#send now accepts strings.
  • [Android] Improved Kernel#rand to accept ranges (of fixnums and floats).
  • [Android] Fixed a bug where undefined local variables or methods returned false instead of raising an exception.
  • [Android] Fixed a bug where Java getter/setter shortcuts would sometimes not work.
  • [Android] Fixed a bug where a crash would happen when running a spec with a lot of test cases.
  • [Android] Fixed memory leaks when symbolicating an exception backtrace.

sudo motion update

Announcing RedPotion, the Rails of RubyMotion


image

The makers of RMQ at InfiniteRed and the creators of ProMotion at ClearSight as well as David Larrabee have teamed up to create the ultimate RubyMotion library: RedPotion.

image               image

Our goal is to create the Rails of RubyMotion, to be opinionated, and make best practices trivial.

We’ve taken ProMotion, mashed it up with RMQ, added some sugar, and selected a set of gems that covers everything you need, such as CDQ, afmotion, motion_print, etc.

The sugar we’ve added hides RMQ and makes it more ProMotion like, adds consistent methods to views and controllers, and generally makes a super nice consistent experience.

Here is some example code to give you the flavor of it:

class HomeScreen < PM::Screen
  title "My Awesome App"
  stylesheet HomeScreenStylesheet

  def on_load
    set_nav_bar_button :left, system_item: :camera, action: :nav_left_button

    append SectionView, :section

    @image_url = append!(UITextField, :image_url)
    @sample_image = append!(UIImageView, :sample_image)

    append(UIButton, :load_image).on(:touch) do |sender|
      @sample_image.remote_image = @image_url.text
    end

    append(UIButton, :open_tasks).on(:touch) do |sender|
      open TasksScreen.new(nav_bar: true)
    end
  end
end

In RedPotion, you can use RMQ plugins and ProMotion add-ons.

Here is a blog post about it, and the repo.

App of the Week


image

Title challenge – “Football Management designed for mobile” – by Kyan Games

It has a very cool UI, here is a (https://www.youtube.com/watch?v=dVxzSpKP-x8).

Gems:

  • bubble-wrap
  • ib
  • ruby-xcdm
  • motion-support

Pods:

  • SWRevealViewController
  • MagicalRecord
  • SSZipArchive

CDQ tip by Ken Miller


Every CoreData context has a native thread associated with it. For NSMainQueueConcurrencyType, it’s the main thread itself. For NSPrivateQueueConcurrencyType, it’s a private thread maintained by CD itself. If you need to do any work with a context from outside its native thread (and for private contexts, that is always true for your code), you need to do your work by passing a block to performBlock or performBlockAndWait.

Sponsor


My company InfiniteRed sponsors this newsletter by allowing me the time to work on it 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

Wat


This week’s “App of the Week” has a crazy press page. I mean it’s very cool, but that’s a lot of work, good job Kyan team.

One more thing


I know the Dispatch doesn’t come out as often these days, but I hope you feel the quality has gone up, that every issue is packed with super useful information.


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

Issue #53

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

Issue #52

RubyMotion Android is in motion

At InfiniteRed we’ve been building a real (for existing users) RubyMotion Android app, Darin Wilson has been doing all of it. It’s the Android version of an iOS app we’ve already built. I wanted to give you an update on Android and share some of our experiences.

First: Darin is going to do an RM Android tip in every Dispatch, to help everyone out.

Second: there are still issues with RM Android. Darin is submitting bug reports daily as he finds bugs or missing pieces. As you can see from RM v3.3 below they’re getting fixed.

We’ll keep you updated as Darin continues to travel the undiscovered country, hacking through the prickly foliage.

Continue reading

Issue #51

2015

Happy New Year. This is going to be a great year for RubyMotion. Android was finally released, the Apple Watch is coming, and much more.

For those new to the RubyMotion community, every year there is the #inspect conference for RubyMotion. The date hasn’t been announced this year, but last year it was in May so that’s a good guess.

Continue reading

Issue #50

2015 is going to be awesome for RubyMotion

image

RubyMotion news has been slow lately, especially around the holidays. However there are a few exciting things coming soon to the RubyMotion community. One I can’t tell you about, I’m sorry. The other is a new gem that is a group collaboration.

Many authors of popular RubyMotion gems have teamed up to create something new and special. We’re still working on the basic features of the new gem so I can’t announce it today, perhaps in a few weeks. It’s pretty cool, stay tuned.

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

Happy coding, Todd Werth (@twerth)

Articles, News, New Gems, and Blog Posts


December 3rd, 2014 | blog post | by Nicky Hajal
How I Built My First Native OSX App in Just 6 Weeks Using RubyMotion

December 2nd, 2014 | video | by PhraseApp
Translating RubyMotion Apps with PhraseApp

December 2nd, 2014 | screencast | by Jack Watson-Hamblin
RubyMotion for Rails Developers: Auto-Layout (part 2)

December 1st, 2014 | new gem | by Shirk
motion-crescentia – RubyMotion wrapper for the Calabash BDD framework

November 24th, 2014 | screencast | by Jack Watson-Hamblin
RubyMotion for Rails Developers: Auto-Layout (part 1)

November 19th, 2014 | new gem | by Ryan Linton
medic – A RubyMotion wrapper for HealthKit

November 18th, 2014 | blog post | by Jamon Holmgren
ProMotion 2.1.0 Released – Notable Changes

November 18th, 2014 | blog post | by Gavin Morrice
RubyMotion Tutorial for Beginners: Part 2

November 18th, 2014 | blog post | by Gavin Morrice
RubyMotion Tutorial for Beginners: Part 1

November 17th, 2014 | blog post | by Sam Bauch
Making Fabric Play Nice with RubyMotion

November 14th, 2014 | blog post | by Jamon Holmgren
Annoying iOS issues: ApplicationVerification Failed

November 13th, 2014 | blog post | by Roel Bondoc
Rubymotion and Apple TestFlight

Hidden Gem by Gant Laborde


Random Colors for Layouts

Recently I was laying out a design with grid with RMQ’s online grid playground. The ability to easily have each view on the grid take on a separate color, really helps with the contrast of juxtaposed views. If you find yourself in a similar situation with an actual app, the common way was to (usually from the REPL) run:

rmq(UIView).style { |st| st.background_color = rmq.color.random }

That’s quite a line of code! We do this often enough for it to merit a nice shortcut. Currently in RMQ edge, and in RMQ 1.0, you can easily contrast your view with:

rmq(UIView).debug.colorize

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


image

RubyCaribe is a conference for intermediate and advanced software developers who use Ruby, Rails, and related technologies. Located in Barbados, the eastern-most island in the Caribbean. Laurent will be speaking there.


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

Issue #49

Happy birthday Dispatch

It’s the one year anniversary of the RubyMotion Dispatch, which is crazy. I wanted to personally thank all our readers and the authors that produce the content we publish or link to. To celebrate, we’ve compiled a list of those authors, you can see the full list here.

To all the authors who have appeared in the Dispatch, thank you

image

A special thanks to Josh Heyer for making this collage.

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

Happy coding, Todd Werth (@twerth)

Articles, News, New Gems, and Blog Posts


November 10th, 2014 | screencast | by Jack Watson-Hamblin
MotionInMotion – RubyMotion for Rails Developers: Views in depth (Part 1)

November 6th, 2014 | blog post | by Richard Taylor
Asset Catalogs with RubyMotion

November 5th, 2014 | blog post | by Richard Taylor
Using iOS8 Launch Screens with RubyMotion

November 2th, 2014 | screencast | by Jack Watson-Hamblin
MotionInMotion – RubyMotion for Rails Developers: View Controllers in depth (Part 2)

RubyMotion News


New 2.38 released

  • Optimized the app executable size when a project has too many Ruby source files, by removing unnecessary internal code. ~30-60% lighter.
  • Disabled armv7s support for iOS projects. If you want to add armv7s support back, simply add the ‘armv7svalue to theapp.archs[‘iPhoneOS’]` config in the project’s Rakefile. This architecture is no longer enabled by default in Xcode.
  • Fixed a bug where a compiled Core Data model would be removed when cleaning when an original xcdatamodeld was not available.
  • Fixed a bug where in certain circumstances cleaning would try to be performed when the vendor dir, e.g. vendor/Pods did not exist.
  • Fixed a few cases where the Yosemite version number was parsed incorrectly.
  • Added support for axel as an alternative to curl when downloading updates, which supports resuming and uses 10 connections to improve speed. Axel is available from http://wilmer.gaast.net/main.php/axel.html or can be installed through Homebrew: $ brew install axel.
  • Fixed a regression where rake spec did not work on OS X platform.
  • Fixed a bug where Dispatch.once did not work correctly with x86_64 on iPhone simulator and i386 on OS X platforms.
  • Fixed a bug where :cflags for :static vendored projects could not override those set by the toolchain by default. E.g. -fno-modules.
  • Fixed the motion --version command invocation to print both the stable and pre-release versions of RubyMotion.
  • [OSX] Fixed a bug where embedded frameworks would not be codesigned as per the current requirements for the App Store.
  • [iOS] Removed Symbols not found... message when app will be deployed into iOS device if Xcode dumped device symbols into user directory.
  • [iOS] Fixed a bug which it could not recognized Provisioning Profile which is generated with “iOSTeam Provisioning Profile”.
  • [OSX] Fixed a bug where BigDecimal#inspect would return invalid string on Yosemite.

sudo motion update

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


At InfiniteRed, we’re starting to use ProMotion as well as RMQ on our projects. This should work well as ProMotion is controller-centric, and RMQ is view-centric. As we do this we’re going to create an RMQ plugin (rmq-promotion gem) that does a few nice integrations. Everything works fine now, but we want it to be smoother, especially when using RMQ for styles. We have no timeline yet, but we’re working on it.


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

This year’s authors

ir_authors_770

It’s the Dispatch’s one year anniversary, to celebrate, we want to highlight everyone who contributed content to the Dispatch over the last year.

Access Ninja
Ainame
Alasdair Monk
Alex Rothenberg
Alex kakubei
Amir Rajan
Andrew Gertig
Arkency
Atsushi Nakatsugawa
Austin Seraphin
Baylor Rae
Benjamin Morgan
Bjorn Maeland
BostonMotion
Brian Pattison
Chris Bartling
Christoffer Lernö
Christopher Speer
Clay Allsopp
Clay McIlrath
Colin T.A. Gray
Confreaks
Daniel Spector
Darren Cauthon
Darren Rogan
David Astels
Dennis Major
Drew Carey Buglione
Eiji Iwazawa
Elliott Draper
Eric Henderson
Erwin Boskma
Francis Chong
Fumihiko Shiroyama
Gant Laborde
Garrett Heinlen
Gavin Morrice
Henrik Hodne
Hwee-Boon Yar
ITO SOFT DESIGN
Ignacio Piantanida
Imanol Fernandez
Iskander Haziev
Ivan Acosta-Rubio
Jack Watson-Hamblin
James A. Anderson
Jamie Wagner
Jamon Holmgren
Jaune Sarmiento
Jens Balvig
Jeremy Groh
Jerry John Jacob
JetBrains
Jordan Maguire
Josep
Joseph Ku
Joshua Ballanco
Justin DeWind
Kamatamadai
Kamil Lelonek
Kareem Kouddous
Katsuyoshi Ito
Ken Miller
Kieran Andrews
Landon Schropp
Laurent Sansonetti
Leigh Appel
Lori Olson
Luke Cathie
Mackato
Maethee
Makoto Kawasaki
Marcus Gartner
Mark Rickert
Mark Villacampa
Masashi Shinbara
Mathew Sinclair
Matt Brewer
Matt Garrison
Matt Green
Michael Denomy
Michael Graff
Michal Taszycki
Michał Taszycki
Mirko Stocker
MotionInMotion
Multunus
Multunus Software
Murtuza Kutub
Nader Hendawi
Neeraj Singh
Nelson Pascoal
Nick Arnott
Nick Pachulski
Nicolas Cavigneaux
Nikolay Nemshilov
Notification Center
Orta Therox
Paul Campbell
Paul Sturgess
Philipp Fehre
Qi He
Ray Hightower
Rob Horrigan
Ruby Commotion – RubyMotion Community Projects
Ruby5
RubyKaigi
RubyMotion
RubyMotionJP
Ryan Grey
Satoshi Ebisawa
Satoshi Watanabe
Scott W. Bradley
Shizuo Fujita (Watson)
Sim
Sotaro Omura
Stalin
Stefan Haflidason
Steve Ross
Sunil Kumar
Tatsuhiko Miyagawa
Terrible Labs
Thom Parkin
Thomas Mayfield
Todd Werth
Tony Hillerson
Tony Issakov
Torben Toepper
W.R. de Vos
Wes Garison
Will Raxworthy
Wouter de Vos
Y.Kentaro
Yuki Moriyama
Yuki SHIDA
bellx2
digitalfx
kyamaguchi
moriyaman
t_nakamura
utwang

A special thanks to Josh Heyer for making the avatar collage above.

Issue #48

People like the new by-week/alert format of the Dispatch

After I sent out the first alert last week, some people contacted me and they liked the idea. So I’ll go ahead and use the new system.

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

Happy coding, Todd Werth (@twerth)

Articles, News, New Gems, and Blog Posts


October 31st, 2014 | slide deck | by Michał Taszycki
Ruby – Write Once, Run Anywhere – Polyconf 2014

October 30th, 2014 | blog post | by Mark Rickert
Prepending the Default RubyMotion Build Task [UPDATED]

October 29th, 2014 | blog post | by Philipp Fehre
Using Couchbase Lite from RubyMotion

October 26th, 2014 | screencast | by Jack Watson-Hamblin
MotionInMotion – RubyMotion for Rails Developers: View Controllers in depth (Part 1)

October 26th, 2014 | video | by Nikolay Nemshilov
Native iOS Development with RubyMotion and UnderOS

October 20th, 2014 | blog post | by Brian Pattison
Ruby All the iOS 8 Push Notifications!

October 20th, 2014 | screencast | by Jack Watson-Hamblin
MotionInMotion – RubyMotion for Rails Developers: Views and View Controllers

October 15th, 2014 | blog post | by bwarner
App to Distribution to iTunes

RubyMotion News


New 3.0 prerelease (Android)

A new 3.0 prerelease (Android) is out: some compiler and build improvements, more Ruby methods and bug fixes. Enjoy and please keep testing!

sudo motion update --pre

RubyMotion Tip


UIAppearance protocol

The SDK has a concept called the UIAppearance protocol. It’s basically a global place to set various styles.

There are some problems with it:

  • You can only set some attributes on some views and controllers
  • The styles only get applied when a view is created, so you can’t use it for theming, where you need to change the theme while screens are already loaded

You still should use it, because if you can set something’s appearance it saves you from styling it throughout the app.

I usually create an StandardAppearance class like so:

class StandardAppearance
  def self.apply(window)
    Dispatch.once do

      UIWindow.appearance.tap do |o|
        o.tintColor = UIColor.redColor
        # set other attributes here
      end

    end
  end
end

Then I call it in AppDelegate:

StandardAppearance.apply @window

Or if I’m using RMQ (which of course I am), I call it in ApplicationStylesheet so that I can use my named colors, named fonts, etc:

class ApplicationStylesheet < RubyMotionQuery::Stylesheet

  def application_setup
    color.add_named :apricot, '#EEAA22'

    StandardAppearance.apply rmq.app.window
  end

end

The following have attributes you can set with appearance:

  • UIActivityIndicatorView
  • UIBarButtonItem
  • UIBarItem
  • UINavigationBar
  • UIPopoverController
  • UIProgressView
  • UISearchBar
  • UISegmentedControl
  • UISlider
  • UISwitch
  • UITabBar
  • UITabBarItem
  • UIToolbar
  • UIView
  • UIViewController
  • UIWindow

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

TOL

Thinking out loud


I personally have 4 rules for company culture: hire creative people, hire nice people, be honest with them as much as humanly possible, and then let them create the culture. Nothing else is needed.

I liked her talk on company cultures: Rocky Mountain Ruby 2014 – Your Company is “Awesome” (But is “Company Culture” a lie?)


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