A Swiss residence permit – that little card with your photo on it, marked B, C, L or whichever category you have – proves that you are entitled to live in Switzerland. That and nothing more. It is not a travel document. It does not allow you to cross any borders, not even on your way to France or Italy.
To travel, you need your Spanish passport or your valid Spanish national identity card. It doesn’t matter if you’ve been here for ten years on a C permit. It doesn’t matter if you’ve crossed that border fifty times. At border control, what counts is your national identity card, not your Swiss permit. You use the residence permit to prove that you can return to Switzerland once the border official has verified your identity using your Spanish ID card. They are two separate things and are not interchangeable.
The problem crops up every summer. People who have been living here for years go on holiday and discover at the border that their Spanish passport expired months ago, or that they left it at home, thinking their residence permit would be enough. If your passport has expired and you’re in Switzerland: you can stay without any problems; your residence permit is still valid and nobody will bother you. But you cannot leave the country until you have a valid travel document. The Spanish consulates in Bern, Zurich and Geneva have long waiting lists for appointments during the summer. If your passport is due to expire in the coming months, the best time to renew it was three weeks ago. The second-best time is today.
One more thing: the Spanish national identity card is valid for ten years for adults and five years for minors. Many people have been living in Switzerland for years without needing their ID card because their passport is accepted here, and they’ve left it in a drawer without realising when it’s due to expire. If you don’t know when yours expires, check it before you go on holiday.