RubyMotion Notes
RubyMotion 笔记
Libraries to …
How to …
Create a RubyMotion template rubygem, Step by step
- Create a gem project
motion create --template=gem motion-my-template
- Add files and metadata to gemspec
- motion-my-template.gemspec
+ spec.files += Dir.glob('template/**/*.rb')
+ spec.metadata = { 'rubymotion_template_dir' => "template" }
- 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`
- 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.
- Build gem, install, and push to rubygems
rake build
rake install
rake release
- 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 anerb
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
- menubar-popover - use NSPopopver from the menubar
- motion-kit/samples/osx - MotionKit Examples
- motion-osx-ib - Example with
ib
- Motion SourceList Boilerplate - Using
motion-kit
andPXSourceList
- Motion-Tree-CoreData - Using
ib
andmotion_data_wrapper
- Presence for uberZeit -
motion-kit
,SSKeychain
,IYLoginItem
,MASPreferences
- rm-osx-kartta - Map viewer
- rubymotion-avfoundation - Using
AVFoundation
andCoreMedia
- RubyMotionSamples - OS X
- tick-timer - Menubar app using
MenuMotion
andMotionKit