A magic number is a number that is used in code without much meaning due to the lack of context. Magic numbers are considered an anti-pattern because they make code harder to read, understand, and maintain. Refactoring code that uses magic numbers is also more risky and can be time-consuming.
String literals can introduce similar problems. Why is that? A string literal can result in stringly typed code. If a string is used instead of a more appropriate type, then we speak of stringly typed code.
I tend to avoid string literals as much as possible, especially if that string literal is used in several places. The good news is that you can avoid string literals with little effort. In this episode of Code Smells in Swift, I show you a few solutions to avoid string literals and stringly typed code.