1

I am running these hooks:

<hook src="hooks/before-build/controller.js" type="before_build" />
<hook src="hooks/before-build/controller.js" type="before_run" />
<hook src="hooks/after-build/controller.js" type="after_build" />
<hook src="hooks/after-build/controller.js" type="after_run" />

They simply replace variables in the config.xml file so it will be fitted to staging or production environments respectively.

For example, take this line:

<preference name="APP_SECRET" value="ANDROID-APPCENTER-APP-SECRET" />

And replace the secret.

After the build has done, it re-fills the config.xml with the old values again - for next build to have the old references for next use.

In Android this works just awesome - I have different generated config.xml for stage or prod. But in IOS I receive this error when I am trying to run or build:

The product name change (<name> tag) in config.xml is not supported dynamically.
To change your product name, you have to remove, then add your ios platform again.
Make sure you save your plugins beforehand using `cordova plugin save`.
    cordova plugin save
    cordova platform rm ios
    cordova platform add ios

I think that IOS starts to build without async waiting to the hooks to be done. And therefore it tries to build without a proper config.xml file and then having error.

How to tell IOS to await the hook to be ended and by the time this happens, to start building with the new config.xml?

Raz Buchnik
  • 7,753
  • 14
  • 53
  • 96
  • why do you want to have these variables in config.xml? can't you use some other way of storing variables? and what are you doing in the scripts. can you also add that. – yashpatelyk Jun 23 '19 at 13:39
  • I am trying to change config.xml parameters to stage and prod. Config.xml parameters are not dynamic - therefore I rebuild it using the hooks. First stage I take a copy of the config.xml (that have variables placeholders instead of actual values). Replace them. Build the app. Then put the old content of confing.xml (that was saved in temp file) in the config.xml and delete temp file. – Raz Buchnik Jun 23 '19 at 14:14
  • I think I got the problem. I should build with the CLI and then run the app using the Xcode (or run the app via CLI too). Since Xcode actually doesn't build Cordova's app it just runs them. The build should be done beforehand and thats the resolve of the problem. – Raz Buchnik Jun 24 '19 at 08:04
  • does this solve your problem? https://stackoverflow.com/a/41089006/1243247 – João Pimentel Ferreira Sep 21 '20 at 10:05

0 Answers0