Our app has previously not supported dark mode and we had the "Appearance" entry in our Info.plist set to "Light".
We are now about to release an update that enables dark mode support. To enable this we have:
- Added a preference to our app's settings screen that lets users choose between System, Light and Dark options.
- Based on the user's preference, we set the entire app's preferred color scheme using the SwiftUI
.preferedColorScheme
modifier on our root view. - Removed the "Appearance" entry from our Info.plist
This is all tested and working in our local development builds. We are now testing out the app for release using an internal TestFlight build and we've run into a problem - after initially updating the app, it does not seem to detect the change to the Info.plist and the app remains in light mode even if you change the preferred colour scheme.
If you force quite the app from the app switched and re-launch it, the colour scheme preference starts working as expected.
This is going to be an issue for our users because when they update the app it is going to look like the new color scheme setting does not work. Having to ask customers to force quit the app from the app switcher is not really an acceptable workaround.
I'm not sure this is specifically tied to the app process being killed because I would expect that to happen anyway when the app is updated. I'm wondering if this is related to the system caching the UISceneSession for the app and the act of force killing it from the app switcher is what causes the cached session to be created.
Is this a known issue and is there any way to solve this?
Solved: kind of.
We have a custom property wrapper that implements DynamicProperty
to enable remote feature flagging directly in SwiftUI views. We were using this to remotely enable dark mode.
Even though the feature flag was turned on, something about the way this dynamic property wrapper works was causing the view to not set the correct mode on first launch, even when the value changes. We've not had any problems with this property wrapper in other views.
Rather than waste more time trying to figure it out, we decided to simply remove the feature flag around dark mode and ship it directly.