Error accessing openfl.system.Capabilities.language on iOS

When running my game on the iOS simulator, it crashes when I try to access openfl.system.Capabilities.language, with the following error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSCFString stringByAppendingString:]: nil argument' ***

I noticed this issue, but I’m assuming that’s probably not it since it was fixed some years ago.

It works fine on Android, and was likely working on iOS before I updated OpenFL and related libraries.

I think I see where the crash is occurring, maybe the localeRegion value is coming through as nil on your simulator

I made a change here that I think may resolve the issue:

You could try lime rebuild ios with a dev version of Lime

I tried to rebuild the dev version, and got the following error:

Error: ./src/system/System.mm:61:20: error: no matching function for call to 'NSSearchPathForDirectoriesInDomains' NSArray* paths = NSSearchPathForDirectoriesInDomains (searchType, NSUserDomainMask, YES); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSPathUtilities.h:96:40: note: candidate function not viable: no known conversion from 'NSUInteger' (aka 'unsigned int') to 'NSSearchPathDirectory' for 1st argument FOUNDATION_EXPORT NSArray<NSString *> *NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory directory, NSSearchPathDomainMask domainMask, BOOL expandTilde); ^ 1 error generated.

I’ve never seen this error before… perhaps this is caused by a newer iOS SDK

Can you change line 40 from NSUInteger to NSSearchPathDirectory and see if it compiles then?

1 Like

That seems to have fixed it; I was able to compile, and the original openfl.system.Capabilities.language problem is also fixed. Thanks again :grinning:

1 Like