Libraries to …

How to …

Create a RubyMotion template rubygem, Step by step

  1. Create a gem project
    motion create --template=gem motion-my-template
    
  2. Add files and metadata to gemspec
  • motion-my-template.gemspec
+  spec.files        += Dir.glob('template/**/*.rb')
+  spec.metadata      = { 'rubymotion_template_dir' => "template" }
  1. Create files in template directory
mkdir template/{my-template-name}/files/

├── template      ...... correspond to `rubymotion_template_dir` above
│   └── {my-template-name}     ...... template name
│       └── files      ...... always `files`
  1. Add to template files.
  • typical file structure
.
├── Gemfile
├── Gemfile.lock
├── README.md
├── Rakefile
├── lib
│   └── motion-templates
│       └── version.rb
├── motion-templates.gemspec
└── template
    └── circle
        └── files
            ├── Gemfile
            ├── README.md.erb
            ├── Rakefile.erb
            ├── app
            ├── resources
            └── spec

You can use erb as template.

  1. Build gem, install, and push to rubygems
rake build
rake install
rake release
  1. Use the template
  • method 1 (dev), in gem source directory
bundle exec motion create --template=<my-template-name> app_name
  • methods 2(gem), for most other users
gem install motion-my-template
motion create --template=<my-template-name> app_name
  • An example: https://github.com/Lax/motion-templates
  • .gitignore - Since .gitignore file is ignored when building gem or creating target project with --template, you can create an erb file named .gitignore.erb
  • If need more power, refer to the default templates, which can be found at /Library/RubyMotion/lib/motion/project/template/

Sample Projects

OS X