I'm a Spanish national and live in Spain and think Spain is the worst place ever to do business. My advice is the following:
Setup a UK LTd owned 100% by you.
Put a nominee or a parent of yours as the director. (This way the spanish authorities won't be able to say the company is manged form Spain)
Pay yourself dividend from the earnings of your LTD
Declare corporate tax for those dividends in UK
Declare rendimientos del capital from LTD on your Spanish self assessment.
You'll pay taxes but you'll do everything by the book and be free.
There are small variations possible to that, for example you can bill the LTD for management expenses once a year and pay autonomos only for this month every year.
It looks complicated but I actually is very easy once you do it.