When you use the motion create
command of RubyMotion, the default behavior is to create a project that builds an iOS application. But that is only one of many project templates which are available for you to use.
Displaying the help banner of motion create
, you are presented with a list of the available RubyMotion templates.
$ motion create --help
Usage:
$ motion create APP-NAME
Create a new RubyMotion project from one of the following templates:
* android
* flow
* gem
* ios (default)
---
description: This template generates a universal iOS app (iPhone, iPad).
* ios-action-extension
* ios-admob-rewarded-ads
* ios-audio-unit-extension
* ios-broadcast-ui-extension
* ios-broadcast-upload-extension
* ios-call-directory-extension
* ios-content-blocker-extension
* ios-custom-keyboard-extension
* ios-document-provider-extension
* ios-file-provider-extension
* ios-framework
* ios-imessage-extension
* ios-intents-extension
* ios-intents-ui-extension
* ios-notification-content-extension
* ios-notification-service-extension
* ios-photo-editing-extension
* ios-share-extension
* ios-shared-links-extension
* ios-spotlight-index-extension
* ios-today-extension
* ios-watch-app
* osx
* tvos
As you can see, there are a LOT of templates. It used to be that these were embedded as part of the RubyMotion command installation. In recent times, these have been extracted into their own, publicly available, Github repository.
When these templates are updated, you can pull the updates down with the motion repo
command.
If a template has been updated, you will see something like:
$ motion repo
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 7 (delta 3), reused 6 (delta 3), pack-reused 0
Unpacking objects: 100% (7/7), done.
From https://github.com/amirrajan/rubymotion-templates
af6cbc5..775e91c master -> origin/master
Once updated, running the command again is a no-op.
The templates are stored in a “dot” directory, under your home directory. If you have any problems with these templates, you can always delete this directory, and then run the motion repo
command to update it again.
$ ls -al .rubymotion
total 0
drwxr-xr-x 4 lori staff 128 13 Jun 20:51 .
drwxr-xr-x@ 177 lori staff 5664 21 Aug 11:47 ..
drwxr-xr-x 11 lori staff 352 19 Jul 16:06 rubymotion-command
drwxr-xr-x 7 lori staff 224 13 Jun 20:51 rubymotion-templates
The beauty of having these templates in a repository that can be independently updated, is that they are now decoupled from the RubyMotion release cycle. If a problem crops up, it can be fixed without a full RM regression test, saving days of waiting.
And there are gems that you can install, which will add additional templates to this list, like the Red Potion gem(s), which will add:
* redpotion-template
to the list of available templates.
These templates provide a wealth of example implementations for many important iOS application features (like ios-photo-editing-extension), as well as alternative API’s for writing apps (like redpotion-template) and writing apps for other devices (like tvos for Apple TV).
If you’d like to learn more about RubyMotion development, and how to use some of these templates, sign up for our WNDX School of RubyMotion Development mailing list.