So I recently started using the custom TTF support that was added to Label in 0.8.2. The app runs perfectly in the simulator. The TTF Labels are created and look fine. However, when I build my app for the device it crashes. I have cleaned the build but it has not solved the issue. I'm building for 3.1 using the Cocos template. I recently upgraded the project from 0.8.1.
Console reads:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString drawInRect:withZFont:lineBreakMode:alignment:]: unrecognized selector sent to instance 0xd8098'
Debugger reads:
#0 0x32011b5c in __kill
#1 0x32011b50 in kill
#2 0x32011b44 in raise
#3 0x32028e6a in abort
#4 0x32728398 in __gnu_cxx::__verbose_terminate_handler
#5 0x309148a0 in _objc_terminate
#6 0x32725a8c in __cxxabiv1::__terminate
#7 0x32725b04 in std::terminate
#8 0x32725c2c in __cxa_throw
#9 0x30912e5c in objc_exception_throw
#10 0x31ea3bfc in -[NSObject doesNotRecognizeSelector:]
#11 0x31e28b18 in ___forwarding___
#12 0x31e1f888 in __forwarding_prep_1___
#13 0x0008ba34 in -[Texture2D(Text) initWithString:dimensions:alignment:fontName:fontSize:] at Texture2D.m:385
#14 0x0006600c in -[Label setString:] at Label.m:75
#15 0x00065cb0 in -[Label initWithString:dimensions:alignment:fontName:fontSize:] at Label.m:50
#16 0x00065a90 in +[Label labelWithString:dimensions:alignment:fontName:fontSize:] at Label.m:32
I stepped through the whole uiFont creation process and everything seems to work fine as best I can understand it. The crash happens right after the CGRectMake() call is made on line 385, so it would seem that the uiFont selector is the issue?
Not sure if it's relevant, but I am using a custom TTF that a colleague of mine created specially for this game. If the TTF were the issue though I would not expect the app to run OK in the simulator, which it does.