It's concerning to hear that your phone was hacked.
Is there a shell script that you can use to hack cell phones with just their number from your macOS
While there can be no definitive yes/no answer for your query, it can be assured that if you use an iPhone with a reasonably strong password, device passcode, Touch ID/Face ID authentication, two-step authentication (basically you follow reasonable security advisory) and change Apple ID password regularly, you should be in a much better/secure stand. Similar advise applies to users of macOS.
Objectively speaking, Apple's stand on user data privacy is pretty strong and generally, one stands a highly low chance of getting their device or data hacked.
Apple's Privacy page is worth referring to here.