Late to the game but the solution is here:
https://developer.apple.com/documentation/foundation/icloud/synchronizing_app_preferences_with_icloud?language=objc
For each target (iOS and macOS):
In the Xcode project, open the target’s PrefsInCloud.entitlements file.
In that file, go to com.apple.developer.ubiquity-kvstore-identifier entitlement and replace $(CFBundleIdenfier) with your key-value store ID (i.e. $(TeamIdentifierPrefix)your key-value_store ID).
For example if your key-value store ID is “com.mycompany.myKeyValueStoreID” it would look like this:
$(TeamIdentifierPrefix)com.mycompany.myKeyValueStoreID.
It’s important that the key-value store ID portions are the same between both targets.