If you use Color Sets in the Assets Catalog to define your color palette, make sure you enable variants for the Any, Light and Dark appearances and also High Contrast. You'll be able to define variations of the color that have better contrast.

Xcode's Assets catalog. You can create color sets. When doing so, if you select it, you can add appearances for the color (any, light & dark) and enable high contrast colors too, from the Attributes Inspector in the Inspectors Panel (right-side of Xcode).