Smartling/ios-i18n

exc_bad_access on iOS 9

vitalybaev opened this issue · 4 comments

Hi, I'v start using your project, installed via CocoaPods, created sample project and run an app. But simple function [NSString stringWithFormat:SLPluralizedString(@"%@ apples", number, nil), number] terminates app with EXC_BAD_ACCESS

Demo project works well in simulator, but failing compile cause

ld: ../Frameworks/Smartling.i18n.framework/Smartling.i18n(NSBundle+Smartling_i18n.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
paiv commented

EXC_BAD_ACCESS
check the type of the number variable: since you formatting it as "%@", it should be NSNumber

Thanks! Now this code works:

NSNumber *number = [NSNumber numberWithInt:42];
NSString *format = SLPluralizedString(@"%d apples", number, @"Comment");
NSString *text = [NSString stringWithFormat:format, number];

But in your README.md I found this code, that crashes an app:

int number = 42;
NSString *format = SLPluralizedString(@"%d apples", number, @"Comment");
NSString *text = [NSString stringWithFormat:format, number];
paiv commented

@vitalybaev check your format strings, xcode is not highlighting errors in this case
%@ to format NSObjects (NSNumber)
%d to format integers (NSInteger, int)

paiv commented

bitcode issue fixed