Well, it’s a bit more complicated than that.
Back in the “old days”, Apple sold developer tools (compilers, IDEs, documentation, etc.). As did everybody else. And there were third-party developer tools for those who didn’t like Apple’s tools. Many here will be familiar with terms like MPW, Lightspeed/THINK C and Code Warrior - the major commercial developer kits at the time.
At some point in the 90’s and early 2000’s, with the rise of major open source projects, including Linux and its development tools like the GCC compiler suite, users started using free development tools. Initially on various Unix/Linux platforms, and later on everything else as different teams ported those tools to other platforms.
By the time Mac OS X was released, everybody, including Apple was using these free tools (initially GCC, later Clang) with custom tools (IDEs, UI editors, etc) built around them.
By that point, there was really no option but to give away the developer tools for free, because most developers had gotten used to free availability of high quality tools. Apple knew that if they would charge money for the developer tools, most developers would simply use third-party tools, which (rightly or wrongly) Apple assumed would be of inferior quality.
By the time iOS came around, the die was cast and Apple would never consider charging for developer tools and docments.
Apple would lose most of the market if they started blocking third-party software. But I don’t think that’s the same as if they would resume charging money for developer tools.
As long as there is suitable documentation, there will be third-party developer tools, and therefore there will be third-party apps developed with those tools.
Of course, many developers may decide to leave the platform on principle. But it’s all moot, because it isn’t going to happen. The entire software industry worldwide relies on free developer tools and that isn’t going to change any time soon.