Hi
Apple advises that it can be normal for your iPhone to become warm when using it and also in other situations including when charging it, first setting it up, restoring from a backup and when apps re-index or re-analyse data after a software update. The exterior acts as a cooling surface, transferring heat from inside the iPhone to cooler air outside.
Apple also notes that charging your iPhone when it is inside certain styles of case may generate excess heat, which can affect battery capacity. If you notice that your iPhone gets hot when you charge it, Apple advises that you should remove it from its case before charging.
In respect of the charging issue, follow the steps here, including checking the charging port for any lint or other debris:
If your iPhone, iPad, or iPod touch won't charge - Apple Support
Also ensure that you are using either a genuine Apple cable or an Apple-certified / MFi cable. If you are already doing so, try instead using another such cable. Apple also recommends using genuine Apple USB Power Adapters.
When charging your iPhone, be sure to follow all of Apple's safety and handling guidelines, including those detailed here:
- Keeping iPhone, iPad, and iPod touch within acceptable operating temperatures - Apple Support
- http://help.apple.com/iphone/10/#/iphbbe12ba1
- https://www.apple.com/batteries/maximizing-performance/
If the charging issue persists and/or you are concerned that your iPhone gets warmer than it should do, then I suggest that you contact Apple Support (remote diagnostics and mail-in service may be available, if required), make a Genius Bar reservation or visit an Apple Authorised Service Provider with a view to having your iPhone checked and, if recommended, serviced / replaced under warranty:
- US: iPhone Service Answer Center - Apple Support
- Elsewhere: Apple - Support