Search code examples
simperium

Simperium crashes on initWithViewController because of sp_md5StringFromData


When using Simperium in my app, the app quits with this error:

+[NSString sp_md5StringFromData:]: unrecognized selector sent to class 0x19fdfd8

I've debugged the code enough to know that it's crashing in the [[Simperium alloc] initWithViewController:controller] method, in the following code:

UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
    UINavigationController *navController = (UINavigationController *)[tabBarController.viewControllers objectAtIndex:0];
    NotesViewController *controller = (NotesViewController *)[[navController viewControllers] objectAtIndex:0] ;    

self.simperium = [[Simperium alloc] initWithRootViewController:controller];

[self.simperium startWithAppID:@"my-app-ID-goes-here"
                            APIKey:@"the-API-key-would-go-here"
                             model:[self managedObjectModel]
                           context:[self managedObjectContext]
                       coordinator:[self persistentStoreCoordinator]];

I've concealed the AppID and API Key --- that's not a bug! :)


Solution

  • A required category for NSString isn't being loaded. This will happen if you forget to add -ObjC to "Other Linker Flags" under the build settings for your project. If you add that flag and run it again, I think you'll have better luck.