The only way you can play Terraria with your friend is to have similar platforms. If you play on Xbox then you should ask your friend to also play on Xbox. Likewise, if you are a PC player then your friend should also have a PC.