During the XVIII c. Spain was already taking steps towards the industrialization. This process was aborted by all the political troubles in the XIX c., where conservative victories meant steps back, because the bulk of the conservatism in Spain was a nobility that scorned putting their money to work.
There are ways to allow this to continue: have the conspiracy against Floridablanca fail, give continuity to Joseph I (by having Spain accept him as king and strong use of handwavium so the Napoleonic defeat isn't total, i guess), have Ferdinand VII die early and his heir accept the constitution of 1812...
Spain was in decline during the XVIII century only in comparison with power it had during the 2 previous centuries. The Bourbons were not the plague we like to think often in Spain, through the XVIII they greatly modernized Spain. Even though as a Galician nationalist I despise their centralist policies, i can't deny they really improved on the situation they found. The thoroughness of the screw Spain suffers (mostly self-inflicted) from 1808 to 1939 cannot be overstated.
Spain wasn't back then a nation staunchly resistent to modernization, with every politician tightly gripping a Bible. That image only became very partially true during Ferdinand VII's rule, because after the Independence war, every liberal (which included the industrialists) was seen with distrust and called "afrancesado" (frenchized), and more often than not it costed them their lives. Before then, it was merely a more conservative nation, in slight decline, but having reclaimed part of the lost greatness during Charles III reign. The navy had been modernized and the army refitted: the Spanish army wasn't the joke many could think due to the French invasion (which happened through the use of our PM's corruptibility, not militar might).
As i said before, i don't think the Bourbons were a complete disaster

But i have to acknowledge, the scenario of a Hapbsburg victory always intrigued me. An early entente cordiale against a hispano-german axis

haha. Seriously speaking, this would be a huge change over the political balance OTL, i would like to see how it would play out.