Using SF Symbols with a changed global locale

When changing the global locale by
std::locale::global(std::locale(NAME))
where NAME is a valid and supported name of a locale all access using
[UIImage systemImageNamed:@"..."]
fails.

Is there a way to modify the global locale and still have access to the SF Symbols?

Answered by DTS Engineer in 916305022

I wasn't able to reproduce this. In the iOS 27.2 Simulator and in Mac Catalyst in macOS 27.0.1, I changed the global locale with std::locale::global(std::locale(NAME)), both before and after the app finished launching. I also tried setlocale for each category. systemImageNamed: still returned an image every time.

On an iPhone with iOS 27.2.1, I couldn't change the locale at all. Of the names I tried there, setlocale and std::locale accepted only "C", "POSIX", and "", which resolves to "C". Names like de_DE.UTF-8, en_US.UTF-8, and fr_FR.UTF-8 aren't available on the device. std::locale("de_DE.UTF-8") throws an exception with the message collate_byname<char>::collate_byname failed to construct for de_DE.UTF-8, and setlocale returns NULL. In the Simulator and in Mac Catalyst, those names work.

To help me reproduce what you're seeing, could you post:

  • the platform and OS version, and whether it's a device or the Simulator
  • the exact locale name you pass
  • the name of a symbol that fails, and what systemImageNamed: returns for it
  • a small project or code snippet that shows the problem, if you can share one

I wasn't able to reproduce this. In the iOS 27.2 Simulator and in Mac Catalyst in macOS 27.0.1, I changed the global locale with std::locale::global(std::locale(NAME)), both before and after the app finished launching. I also tried setlocale for each category. systemImageNamed: still returned an image every time.

On an iPhone with iOS 27.2.1, I couldn't change the locale at all. Of the names I tried there, setlocale and std::locale accepted only "C", "POSIX", and "", which resolves to "C". Names like de_DE.UTF-8, en_US.UTF-8, and fr_FR.UTF-8 aren't available on the device. std::locale("de_DE.UTF-8") throws an exception with the message collate_byname<char>::collate_byname failed to construct for de_DE.UTF-8, and setlocale returns NULL. In the Simulator and in Mac Catalyst, those names work.

To help me reproduce what you're seeing, could you post:

  • the platform and OS version, and whether it's a device or the Simulator
  • the exact locale name you pass
  • the name of a symbol that fails, and what systemImageNamed: returns for it
  • a small project or code snippet that shows the problem, if you can share one

Hi,

I am using

  • Xcode 27.1 using ObjectiveC++ compiler
  • Tahoe 26.7.1
  • iPad (A16) 27.0 simulator (no exception is thrown) but no system images visible, setting the locale is WORKING!
  • iPhone Duo 27.1 simulator (no exception is thrown) but no system images visible, setting the locale is WORKING!
  • iPhone iOS 27.2 (exception is thrown)
  • std::locale::global(std::locale("de_DE.UTF-8")); (called in -(BOOL) application:didFinishLaunchingWithOptions: as the first statement)
  • all symbols fail, here some examples: @"trash", @"power",@"cpu",@"app.connected.to.app.below.fill",etc. (also cancel and done UIBarButtonItems fail); I show the symbols as images of UIBarButtonItems in the navigation bar or in the (also buggy for other reasons) standard toolbar.

I have to admit that I did not do a detailed testing on the iPhone because I already gave up when the simulator did not work properly. Interestingly, iOS 18 does not have any issues (using a simulator).

PS: I need somehow a working locale because some 3rd party C++ libraries (e.g. AU unit library) I am using rely on a proper setting of the locale for correctly formatted output.