At its heart Apple is a hardware company and everything they do is to drive sales of hardware. An iOS developer is forced to have Apple hardware. They could charge for MacOS and they could charge for XCode. But they don’t because the cost of continued development of those applications is subsidized by hardware sales.