iOS 7.1 - 7.1.2 owners can't open my game

794 Views Asked by At

I have a simple free iOS arcade game not functioning correctly, after installation from the App Store, for owners of an iPhone with iOS 7.1 - 7.1.2. The game is build with Sprite Kit & Objective-C (no Swift what-so-ever) but is very simple in nature & doesn't have any fancy code or complexity to it. It also works wonderfully for anyone with iOS 8.x.x installed. After downloading iOS 7.1 Simulator for Xcode 6, I was able to reproduce the problem: iPhone's 4S, 5 or 5S running iOS version 7.1 - 7.1.2 all crash - So the launch image appears, but when it needs to load up the game from SKScene class called MyScene, it just doesn't open. In crash logs it says the following:

+[SKLabelNode labelNodeWithText:]: unrecognized selector sent to class 0x1022503a0

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[SKLabelNode labelNodeWithText:]: unrecognized selector sent to class 0x1022503a0'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001029a6495 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010270199e objc_exception_throw + 43
    2   CoreFoundation                      0x0000000102a3755d +[NSObject(NSObject) doesNotRecognizeSelector:] + 205

Upon crashing, Xcode brings me to some Apple code page about "dispatch_once" & highlights line 68:

dispatch_once(predicate, block);          Thread 1: signal SIGABRT

Basically, inside MyScene, there's -(id)initWithSize:(CGSize)size method. Inside it, I created

static dispatch_once_t onceMS;
dispatch_once(&onceMS, ^{

Inside dispatch_once, I have 4 things: 1. An instance of audioController is created (a class responsible for playing looped background music). 2. SKSpriteNode spriteNodeWithImageNamed: 3. SKLabelNode labelNodeWithText: 4. SKLabelNode labelNodeWithText:

All of these 4 things are meant to show up once, in the beginning of game startup: they are visual instructions for how to play. The background music is self explanatory. I tried commenting all of this out but it still displayed the same crash logs as before. I proceeded commenting out the entire static dispatch_once & still the game crash. Can someone please give out some wisdom? I don't know what to do due to my lack of experience.

1

There are 1 best solutions below

0
On BEST ANSWER

According to the documentation +[SKLabelNode labelNodeWithText:] is simply not available on iOS7

I have literally no experience with SpriteKit, but you should be able to replace all instances of

SKLabelNode *node = [SKLabelNode labelNodeWithText:@"your text"];

with:

SKLabelNode *node = [SKLabelNode labelNodeWithFontNamed:@"HelveticaNeue-UltraLight"];
node.fontSize = 32;
node.text = @"your text";

You can create your own category on SKLabelNode as well:

@interface SKLabelNode (iOS7Compatibility)
+ (instancetype)mba_labelNodeWithText:(NSString *)text;
@end

@implementation SKLabelNode (iOS7Compatibility)
+ (instancetype)mba_labelNodeWithText:(NSString *)text {
    SKLabelNode *node = [self labelNodeWithFontNamed:@"HelveticaNeue-UltraLight"];
    node.fontSize = 32;
    node.text = text;
    return node;
}
@end

which allows you to use:

SKLabelNode *node1 = [SKLabelNode mba_labelNodeWithText:@"your text"];

You must not name the category method labelNodeWithText:, because you don't want to overwrite methods in categories.