I would say that the original structure was "to spend [time] on/in doing something". Here, the ING form is a gerund, e.g.
1. He spent years [on] training himself to write.
and the underlined phrase acts as a complement.
However, without the preposition, the gerund seems to take on something of the character of a participle, as if it were really:
2. He spent years, training himself to write.
This seems illusory, though, as you don't say simply "he spent years": the phrase needs its complement.
(But I may be barking up entirely the wrong tree.)
MrP