Color.primary blending in with darkmode background on AppIntent snippet view

The main problem here is that sometimes the snippet view has black text on a black background and it is unreadable.

To see what might be affecting this:

I tried checking the colorscheme enviroment value via @Environment(.colorScheme) in my view. This usually returns the correct device light/dark mode, however it returns incorrect after device restarts or app is updated. In order to correct this, user must toggle light/dark mode in device settings.

I also tried checking UITraitCollection.current.userInterfaceStyle in the perform() function of my AppIntent. This also usually returns the correct value, but does not after user toggles light/dark mode in device settings. In order to correct this, user must open the app.

The idea with checking these variables was that if one always returned the correct mode, I could set the text to the correct color instead of using .primary. Neither value seems to be 100% accurate and they fail in opposite situations.

Color.primary seems to align with the colorscheme environment variable. When we get the wrong value here (not cooresponding to the set device value), we will see something like black text on black background. Our returned view has no background set, so it matches the containing view. Colorscheme will say that the device is in lightmode when it is in darkmode, so although we have the correct background color, Color.primary is incorrect and the text is unreadable/hard to read.

Is there a solution that will never show unreadable text color besides forcing the view to have a specific colored background and specific colored text?

Our recommendation is to use semantic colors so they automatically adapt. It sounds like you're doing that, but sometimes it's not working? Here's an older thread where another developer seemed to be having the same issue, and was able to reproduce the error with our sample app. Can you do the same, and compare to my screenshots from that thread?

— Ed Ford,  DTS Engineer

Color.primary blending in with darkmode background on AppIntent snippet view
 
 
Q