Licenses issued in third countries can be exchanged if a bilateral agreement with Spain exists — without taking any exams.
These countries
include, for example: Argentina, Ukraine, Colombia, Peru, Turkey, Moldova, Japan, Korea, Uruguay, Georgia, and others.
If there is no agreement, you'll need to take the exams in Spain under the general requirements
To do this, your license must be valid, you must not be disqualified from driving, and you must hold a document proving your Spanish residency (TIE or CUE)