I moved to Spain 5 years ago and have been gradually working through this problem ever since.
I recommend setting yourself up as an aut?nomo to begin with. This means paying a set fee to the government to cover social security contributions (I pay around ?250 per month). Once you are set up as an aut?nomo you can legally work for yourself and then decide how to proceed from there.
If you decide to set up a limited company (SL) you will need to be aut?nomo anyway.
I seriously recommend speaking to a lawyer about all of this. The system is very different to the UK and full of red tape. It is very easy to make mistakes that can potentially lead to big fines - especially where tax is concerned.
If anyone is moving to the Barcelona area fell free to get in touch. I would be more than happy to point you in the right direction (as far as possible) and share my experiences with you.
Thomas