Smartling / ios-i18n

The ios-i18n library provides seamless integration of plurals into iOS 6 apps.
http://www.smartling.com
Apache License 2.0
205 stars 36 forks source link

exc_bad_access on iOS 9 #20

Closed vitalybaev closed 9 years ago

vitalybaev commented 9 years ago

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 9 years ago

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

vitalybaev commented 9 years ago

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 9 years ago

@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 9 years ago

bitcode issue fixed