faugusztin commented on issue #1422:
URL: https://github.com/apache/cordova-ios/issues/1422#issuecomment-2423757190

   Reproduction case with order of steps where pod installation fails is [at my 
repository](https://github.com/faugusztin/cordova-ios-bug-1422) with 
cordova-ios 7.1.1. 
   
   What triggers it is if we have config.xml and package.json configured with 
the plugin which requires increased deployment-target and then we run `cordova 
prepare` or `cordova platform add ios`
   
   - either of those two commands calls cordova-lib to download the platform if 
the platform doesn't exist in the platforms directory. Up until the platform is 
ready, any ConfigParser for config.xml grabs the project root config.xml.
   - after platform is created, there is a new config.xml inside 
platforms/ios/_PROJECT_NAME_/config.xml. This config.xml doesn't have the 
deployment-target set at this moment.
   - restore-util.js inside cordova-lib is called, which identifies the need to 
install plugins based on package.json
   - it then calls cordova-ios lib/Api.js addPlugin method
   - addPlugin then sees plugin requires pods, adds the required changes to 
Podfile, and then runs `pod install --verbose`, which fails, because Podfile 
iOS target is set to default value of 11.0, as 
platforms/ios/_PROJECT_NAME_/config.xml doesn't contain the deployment-target 
property.
   - this all happens before cordova-ios/lib/prepare.js is called, which then 
calls the updateConfigFile method inside the same file, which sets the 
deployment-target in config.xml. But this is too late for the Podfile 
generation and pod install commands executed withing the addPlugin method in 
previous step.
   
   The reason for this order is in 
[prepare.js](https://github.com/apache/cordova-lib/blob/12.0.1/src/cordova/prepare.js).
 The order here is:
   - add platforms from config.xml 
([prepare.js](https://github.com/apache/cordova-lib/blob/12.0.1/src/cordova/prepare.js#L37)
 -> 
[restore-util.js](https://github.com/apache/cordova-lib/blob/12.0.1/src/cordova/restore-util.js#L35))
   - add (install) plugins from config.xml - 
([prepare.,js](https://github.com/apache/cordova-lib/blob/eb00bdca9d44b903eb38e1bef5d73d41386b88e3/src/cordova/prepare.js#L48)
 -> 
[restore-utl.js](https://github.com/apache/cordova-lib/blob/eb00bdca9d44b903eb38e1bef5d73d41386b88e3/src/cordova/restore-util.js#L158))
   - prepare each platform 
([prepare.js](https://github.com/apache/cordova-lib/blob/eb00bdca9d44b903eb38e1bef5d73d41386b88e3/src/cordova/prepare.js#L52))
   
   There are two solutions i can think of:
   - adding the platform should already merge the platform specific settings 
present in config.xml from the project root into the platform specific 
config.xml. That would be somewhere inside the [lib/Api.js 
createPlatform](https://github.com/apache/cordova-ios/blob/a8f9c5726af012e4efa60b222857ae0252c47099/lib/Api.js#L119)
 method.
   - alternatively pod install commands shouldn't be executed within 
cordova-ios until [lib/prepare,js 
upateConfigFile](https://github.com/apache/cordova-ios/blob/a8f9c5726af012e4efa60b222857ae0252c47099/lib/prepare.js#L141)
 method is executed, as that is the moment when the config.xml file is actually 
up to date with settings from the project root config.xml.
   - within cordova-lib/prepare.js swap the order of prepare and plugin 
install, that is call platform prepare first, then add plugins (but this is 
both a change outside cordova-ios and also possibly a breaking change if 
someone relies on current order of calls)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to