We also had unexpected crashes on launch on iOS 17 due to using NSDecimalRound. We have followed the suggestion from the known issues in the Xcode 16 RC Release notes by writing a designated class in Objective C and calling the NSDecimalRound function from objective C instead of from Swift.
This prevents the crash.
Below our code:
// DecimalRoundFix.m
#import "DecimalRoundFix.h"
@implementation DecimalRoundFix
+(void)round:(nonnull NSDecimal *)result number: (nonnull NSDecimal *)number scale: (NSInteger) scale roundingMode: (NSRoundingMode) roundingMode {
NSDecimalRound(result, number, scale, roundingMode);
}
@end
// DecimalRoundFix.h
#import <Foundation/Foundation.h>
@interface DecimalRoundFix : NSObject {
}
+(void)round:(nonnull NSDecimal *)result number: (nonnull NSDecimal *)number scale:(NSInteger) scale roundingMode: (NSRoundingMode) roundingMode;
@end
Then in your Swift code replace everywhere:
NSDecimalRound(&result, &number, scale, roundingMode) with DecimalRoundFix.round(&result, number: &number, scale: scale, roundingMode:roundingMode).
Topic:
App Store Distribution & Marketing
SubTopic:
TestFlight
Tags: