It wasn't just defense sector, Iran had the highest science growth rate in the world during Ahmadinejad era. he advanced Iran's aerospace programs, nuclear energy program, defense industries, infrastructure projects throughout the whole Iran, etc.
Ahmadinejad's unprecedented speed frightened world powers (east and west), so they united to apply the harshest sanctions on Iran in his last years of presidency, particularly Iran's access to swift system was blocked, naturally this affected Iran's economy specially the currency rate.
Then Rouhani with the promise of fixing all economic problems through lifting the sanctions was elected, he shut down all infrastructure and R&D projects (in all sectors), and with the policy of open market, opened import doors, for example Iran's import from china tripled in less than two years! and as what we expect from Reformists, he trusted the U.S with a shitty deal; but they didn't remove the main sanctions which was access to currency exchange system, so Iran couldn't access to the money which was superficially released after the deal, Iran could sell oil, but couldn't receive it's money! so again Rouhani started to import further foreign products instead of the oil money, naturally thousands of domestic production lines were closed in 2015 (the year which JCPOA was implemented) and following years.
and now in 2018, we are seeing the results of his policies, dollar's value has tripled since the sign of that shitty deal and it's going up with a sharp angle, Iran's economy is much much worse than the time of harshest sanctions during Ahmadinejad era.
and yes, defense sector is in coma too, Rouhani reduced defense ministry's budget by 85%, almost no new achievement during Rouhani era and especially recent years, all defense projects are facing several years of delays.