In the past some tech companies would sell their products with minimal margins; the number of products being sold and the various upsells and software sold along with it would justify this. The original PS4 was a good example of this, where Sony actually incurred a loss on the console initially.
The same cannot be said for Apple, and probably most premium phones nowadays. The new iPhone X is supposed to cost just $370 to manufacture according to IHS Markit. This gives them a tidy 170% markup or 63% gross margin on the phone. For the cheaper iPhone 8 and iPhone 8 Plus the cost to manufacture is at $247.51 and $277.66 giving them gross profit margins of 64.6% and 65.2%, respectively.
In reality, this is not the case though, as other factors drive down the gross profit margins, and Apple actually aims for between 38% and 38.5% for the current quarter.
These different numbers are because the cost analysis just takes into account building the actual phone, it does not factor in wastage from quality control or licencing cost. Third parties also sell their products so they will be buying the phones under RRP. Then there are also all the logistics involved with getting the phones from the manufacturing plant to your doorstep and marketing.
It is unsurprising, however, that the cost analysis concluded that the new iPhone X is the most expensive iPhone ever made. IHS Markit estimates the cost of the display module, which includes the cover glass, AMOLED panel and Force Touch sensor, at $110.
With all 3 phones in the range sharing roughly the same gross profit margin, the $999 price might not be as ridiculous as many people claim.