rubymotion-community / sugarcube

Some sugar for your cocoa. RubyMotion helpers.
Other
422 stars 66 forks source link

undefined method `uicolor' for "#ffffff":String (NoMethodError) #180

Closed satoyos closed 9 years ago

satoyos commented 9 years ago

I updated SugarCube from 2.xx to 3.0.3, and encontered RunTimeError;

undefined method `uicolor' for "#ffffff":String (NoMethodError)

Below is my sample code of app_delegate.rb. (sample project)

class AppDelegate
  TEST_COLOR = '#ffffff'.uicolor # => NoMethodError after 3.0.3 update

  def application(application, didFinishLaunchingWithOptions:launchOptions)
    rootViewController = UIViewController.alloc.init
    rootViewController.title = 'test_sugar_string'
    rootViewController.view.backgroundColor = '#888888'.uicolor # <= This works well!

    navigationController = UINavigationController.alloc.initWithRootViewController(rootViewController)

    @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
    @window.rootViewController = navigationController
    @window.makeKeyAndVisible

    true
  end
end

Any advice for my code?

colinta commented 9 years ago

Very interesting - can you output the app.files from your Rakefile?

satoyos commented 9 years ago

Thanks for responding!

Below is app.files from Rakefile in my sample project.

["./app/app_delegate.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/version.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/all/sugarcube/log.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/all/sugarcube/look_in.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/cocoa/sugarcube/log.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/cocoa/sugarcube-to_s/calayer.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/cocoa/sugarcube-to_s/nserror.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/cocoa/sugarcube-to_s/nsindexpath.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/cocoa/sugarcube-to_s/nslayoutconstraint.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/cocoa/sugarcube-to_s/nsnotification.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/cocoa/sugarcube-to_s/nsset.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/cocoa/sugarcube-to_s/nsurl.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/ios/sugarcube-to_s/uicolor.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/ios/sugarcube-to_s/uievent.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/ios/sugarcube-to_s/uilabel.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/ios/sugarcube-to_s/uitextfield.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/ios/sugarcube-to_s/uitouch.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/ios/sugarcube-to_s/uiview.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/ios/sugarcube-to_s/uiviewcontroller.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/ios/sugarcube-color/fixnum.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/ios/sugarcube-color/nsarray.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/ios/sugarcube-color/nsstring.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/ios/sugarcube-color/symbol.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/ios/sugarcube-color/uicolor.rb",
 "/Users/yoshi/src/motion/test_sugar_string/vendor/bundle/ruby/2.0.0/gems/sugarcube-3.0.3/lib/ios/sugarcube-color/uiimage.rb"]
colinta commented 9 years ago

Yup, OK, I'll push a fix. It's appending instead of prepending the files.

satoyos commented 9 years ago

Oh! That's it! The problem is fixed after I changed the order in app.files.

colinta commented 9 years ago

Awesome! Thanks for checking. Fixed in 3.0.4 (pushed to rubygems), can you verify that?

satoyos commented 9 years ago

I've verified it with 3.0.4 !! Thanks for your quick responding and fixing !

colinta commented 9 years ago

My pleasure! It's much easier than waiting, and having the issues build up :smiley: