Just use the Do Not Disturb feature on iOS
I’m saying that it doesn’t work well because Do Not Disturb blocks all notifications.
Do Not Disturb has a variety of options on iOS that can allow calls from your contacts and blocks all others.
While calls do get through from your contacts, you don’t get notifications for anything.
I really just want a contacts whitelist, but since that isn’t an option I use nomorobo which is a subscription service that works really well to block spam calls for $2/month. It’s an iOS app, focuses on not uploading your stuff to their servers, and doesn’t collect your call logs.