I’m blogging this because the user interface in different parts of iOS isn’t consistent so it’s not immediately obvious how to do it.
Supposing you receive a spam/unwanted text from a particular number (a full number or shortcode, doesn’t matter.)
– open Messages and view the conversation
– Click the (i) symbol in top right corner
– Click phone number on following screen (not the icons, to the left of the screen where the actual number is, you may not think it’s clickable but it is)
– The next screen will have a Block this caller link at the bottom
This is confusing because there are other ways to bring up a similar screen but without the Block option at the bottom.
Tested in iOS 10.1 and 10.2