You forget one thing: 3rd-party libraries and frameworks, such as Unity. If the developer had included any breached 3rd party library, his App would still be injected.
There're hundreds of thousands of user created libraries out there and it's virtually impossible for Apple to prepare all these libraries on its cloud compiler. It's not even possible for Apple to make a whitelist for these 3rd party components.
It's not the first time that some 3rd party libraries were found to be vulnerable, or even breached, and a bunch of Apps were affected. Basically XcodeGhost is also a 3rd party library attack, since the hacker had done nothing but modified the default project template, to preload a block of codes before the "real" codes being executed.
Technically, XcodeGhost doesn't do anything "bad". An App is supposed to collect user data and send back for analyzing, especially for these which use internet services extensively. The only problem is that the customers, as well as creators, were unaware of such behavior.
Thanks to Apple's hysteria on privacy, these "malicious code" must still follow Apple's rule. It still can't savage your system, insert any executable. nor access anything you have not permitted. It can only collect very restricted, semi-anonymous information from your phone, without further permission. Now we all know why Apple behaved such a control freak.