capacitor icon indicating copy to clipboard operation
capacitor copied to clipboard

Platform-specific config

Open byronigoe opened this issue 4 years ago • 2 comments

Bug Report

Capacitor Version

Latest Dependencies:

  @capacitor/cli: 3.3.2
  @capacitor/core: 3.3.2
  @capacitor/android: 3.3.2
  @capacitor/ios: 3.3.2

Installed Dependencies:

  @capacitor/android: not installed
  @capacitor/ios: not installed
  @capacitor/cli: 3.3.2
  @capacitor/core: 3.3.2

Platform(s)

iOS, Android

Current Behavior

Run npx cap init, answer Y to "Migrate Cordova preferences from config.xml?". Any preferences inside a "platform" tag (i.e. <platform name="android"></platform> tag, or <platform name="ios"></platform>) is ignored.

Furthermore, the documentation does not explain how those platform-specific preferences can be set, whether in capacitor.config.json or elsewhere. The closest reference is

If your plugin requires variables or settings to be set, you’ll need to apply those configuration settings manually by mapping between the plugin’s plugin.xml and required settings on iOS and Android.

Does this mean manually editing the config.xml in the individual platform directories? That won't work because npx cap copy overwrites it.

Expected Behavior

Cordova supports the <platform> tag, which can wrap other elements. There should be a clearly documented way to support platform-specific config in Capacitor that survives npx cap copy.

Additional Context

See #2246

byronigoe avatar Dec 05 '21 22:12 byronigoe

Any updates? It's realy usefull feature!

vovka-s avatar Jan 27 '22 15:01 vovka-s

Yep, would be nice to have, now I cannot insert my APP_SECRET: depending on platform

milkov85 avatar Mar 17 '22 10:03 milkov85

There doesn't seem to be a plan

Lyfei avatar Mar 01 '23 01:03 Lyfei

Take a look at our Trapeze project which can handle many of these tasks: https://trapeze.dev/

It supports environment variables and can modify iOS and Android projects and is a good substitute for (and even goes beyond) some of the old platform and plugin configuration features Cordova has

mlynch avatar Mar 01 '23 01:03 mlynch