Prince Harry has reached a settlement with the publisher of The Sun over allegations of illegal information gathering.