HipByte / motion-game

Cross-platform game engine for RubyMotion
BSD 2-Clause "Simplified" License
63 stars 18 forks source link

Unable to use non-RubyMotion gems with MotionGame. #31

Closed patrick-gleeson closed 7 years ago

patrick-gleeson commented 8 years ago

Forgive me if I'm being stupid: A lovely part of the RubyMotion toolkit is MotionBundler, that allows me to include any old gem in my RubyMotion project and require it when necessary. However, when using the motion-game template and MotionBundler, those requires suddenly cause a runtime error with message require is not supported in RubyMotion.

If I can't use MotionBundler to require my gems in a MotionGame project, how can I use them?

andrewhavens commented 8 years ago

I recently came across this issue as well. Actually it has to do with how the motion-game rake tasks load the Ruby code. For example, when you run rake ios:simulator this is what happens:

  1. Rake looks for the ios:simulator rake task (defined here).
  2. The rake task invokes rake again, loading just your config/ios.rb file (skipping Bundler.require in your main Rakefile)

Now that I figured that out, it should be as simple as requiring any gems that you want to use in your config/ios.rb, android.rb, etc.

patrick-gleeson commented 8 years ago

Nice, this sounds really promising. I'll investigate when I get a minute.

hugoerg56 commented 8 years ago

I require the gems I need on the config/ios.rb example:

require 'bubble-wrap'
require 'bubble-wrap/reactor'
require 'bubble-wrap/location'
require 'bubble-wrap/mail'
require 'motion_print'
require 'motion-social'
require 'sugarcube-nsdata'
require 'sugarcube-animations'
require 'helu'

Motion::Project::App.setup do |app|
  # Use `rake ios:config' to see complete project settings.

and works really good