rubymotion-community / sugarcube

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

Calling Object.const_get results in error #103

Closed klancaster closed 10 years ago

klancaster commented 11 years ago

I need to call Object.const_get to change a string to a constant, but when I do, I get the following error:

013-10-04 19:06:36.373 MultiScanR[56515:a0b] uninitialized constant SugarCube::Adjust (NameError) 2013-10-04 19:06:36.377 MultiScanR[56515:a0b] * Terminating app due to uncaught exception 'NameError', reason: 'uninitialized constant SugarCube::Adjust (NameError) ' * First throw call stack: ( 0 CoreFoundation 0x021275e4 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x005758b6 objc_exception_throw + 44 2 MultiScanR 0x0032674a _ZL10__vm_raisev + 346 3 MultiScanR 0x003267f5 rb_vm_raise + 165 4 MultiScanR 0x00257c11 rb_exc_raise + 17 5 MultiScanR 0x00254686 rb_name_error + 134 6 MultiScanR 0x002e43ab rb_mod_const_missing + 171 7 MultiScanR 0x0031ccff _ZL20dispatch_rimp_callerPFP11objc_objectS0_P13objc_selectorzEmS1_iPKm + 46303 8 MultiScanR 0x00303f93 rb_vm_dispatch + 5459 9 MultiScanR 0x002e512a rb_const_get_0 + 1210 10 MultiScanR 0x002e5160 rb_const_get + 32 11 MultiScanR 0x0031fa6a rb_vm_const_lookup_level + 282 12 MultiScanR 0x0011d9b3 vm_get_const + 227 13 MultiScanR 0x00122e42 rb_scope + 114 14 MultiScanR 0x0012689f MREP_0E65F77864BB49229D477A80B4BB585F + 7535 15 MultiScanR 0x0002d519 RubyMotionInit + 665 16 MultiScanR 0x0002d8cd main + 109 17 libdyld.dylib 0x03385725 start + 0

Any idea what might be going on?

colinta commented 11 years ago

what string are you passing to const_get? any string? there's no obvious reason this should happen.

klancaster commented 11 years ago

I passed in the name of an existing module, but then tried just passing in "Module". Same results for both.

klancaster commented 11 years ago

EDIT. As a followup, commented out all references to SugarCube in the rake file and all #includes, and the code works as it should, so there is an interaction going on someplace. A little further testing and it looks like if I include SugarCube::CoreGraphics and not SugarCube::Adjust, the crash does not occur. If I include SugarCube::Adjust in the console, it also avoids the crash, making it appear that this is a module load order issue. Any ideas?

colinta commented 10 years ago

Code or sample project please. Can't reproduce.