I have a problem at the intersection of CMP for iOS, Xcode previews and preview locales.
I have a Composable implemented in CMP. I have set it up such that I can correctly preview it in Xcode (using a combination of
ComposeUIViewController
and
UIViewControllerRepresentable
)
Copy code
MyComposable(state: somePreviewState)
My problem is that when I try to preview this in multiple locales, the locale information seems to get lost somewhere in between the Xcode preview and my Composable.
This still shows the English preview.
Anyone has run into this? Any ideas on how to get a Composable implemented in iosMain to recognize the locale passed in from an Xcode preview?
curioustechizen
06/09/2025, 10:52 AM
If anyone else has the same problem, I was not able to get this to work. There is a work-around though.
curioustechizen
06/09/2025, 10:54 AM
If you have a simulator running, or an iPhone connected, then Xcode runs the previews in the connected simulator/iPhone.
I used this feature to change the locale/region settings on the iPhone. Then when I run the preview, the settings from the phone are picked.