Adding Android and iOS with two different appIds

I’m using Capacitor 3.0 and would like to know the recommended way of using a different appId for my Android and iOS platforms for the same app. It’s quite common (see almost all of Google’s apps) to differentiate the platform in the package name (https://play.google.com/store/apps/details?id=com.android.chrome). I think there is a case to be made for supporting two different appIds in the config, but in the meantime I’m looking for the best way of doing this with the format com.myapp.android and com.myapp.ios respectively. Since the capacitor.config.ts only allows for on appId I have two options:

  1. Use something generic like com.myapp then update the projects later in Android Studio and Xcode.
  2. Change the appId in capacitor.config.ts then run npx cap add android, then change it again and run npx cap add ios.

Is one of these better or recommended the other?

You should only be running add once, so you can add one platform, change the id and add the other one.

Or since you are using a .ts file, you can use some env variable or anything you want and add something like this:

appId: process.env.PLATFORM === 'android' ? 'com.android.app' : 'com.ios.app'.

We don’t expose the platform at the moment, so you’ll have to set the PLATFORM env variable yourself. before running add, something like
PLATFORM='android' npx cap add android