What's the best practice to handle multiple environments for one app?

Hi folks,

I’d like to know what is the best practice to have multiple apps for my app in multiple environments? I see some engineers use targets and other use xcconfig files to change the value of bundle identifier, app name, code signing certificates and so on?

So what do you thinks?
For me, I use the second one with using Fastlane. any suggestion?