I have been asked by a Filipina how long does an E U citizen need to be living in Spain before their spouse can obtain a visa to join them?

The position is that a UK citizen having looked at the UK system for a spouse to join their partner in UK is now considering becoming resident in Spain so that they can be together here.

I would be grateful to hear from anyone who has done this in a Schengen Area country. It may also be an option for others.