#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.
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
RubyMotion 3.12 release
- [Android] Added support for Android M (experimental). To target it, set
app.api_version
toMNC
. - [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
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
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
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
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
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
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.
One more thing
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