Tip #1: Never answer a spam call again. Go to Settings > Phone > Silence Unknown Callers and turn it on. This may seem drastic for a first step, but it will solve 90% of most people's issues. This will silence any number that's not in your contacts or recent outgoing calls. If a real person that's not in your contacts needs to get ahold of you, they'll probably leave a voicemail or text you afterward. Just call them back and/or add them to your contacts.
Tip #2: Modern smartphones and their carriers already have a built-in filter that will kick off some spam callers. If you can't use Tip #1 because you need to be able to accept some calls from unknown numbers, try downloading an app like RoboKiller or NomoRobo to enhance your spam filter.
Tip #3: Register your number on the national Do Not Call list. Call 1-888-382-1222 from the phone number that you want to register. This won't stop all of the calls, but it can't hurt... right?
Tip #4: For texts, go to Settings > Messages > Filter Unknown Senders and turn it on. This won't stop spam texts, but it will separate them and clean up your inbox. Don't ever respond to spam texts (or calls, obviously).
Tip #4.5: If none of those helped, just give up. Throw your phone in a river. Thanks spam callers, you ruined everything.