Danny Ackerman
Danny Ackerman

Reputation: 997

Cordova config.xml file getting re-written

I set up a basic Cordova project, and whenever I run cordova build, the config.xml file in IOS gets re-written to defaults, and any preferences I add in the config.xml in my project folder are simply appended to the config.xml in the IOS platform folder. So, for example, by default the config.xml in the IOS folder has < preference name="DisableOverscroll" value="false" /> and when I add that same line (but with True) to the config.xml file in my project folder, the resulting config.xml in the IOS folder ends up having BOTH entries (false and true). How do I get the config.xml file in the IOS folder to have the preferences the way I'm setting them???

Thanks!

Upvotes: 5

Views: 4133

Answers (2)

Danny Ackerman
Danny Ackerman

Reputation: 997

Thanks guys. I think I found the answer last night. There's a default.xml file in the platform folder. Once I modified the default values for the preferences there, they consistently showed up correctly in the config.xml whenever I ran the build command.

Upvotes: 2

James Wong
James Wong

Reputation: 4619

Starting from 3.3.0, config.xml file for all build platforms are created at the project root folder instead of the www folder.

In your case, the second config located in www can be safely ignored, even if the parameter value is false.

Reference: 3 Cordova CLI Changes You Should Know About

--- Update: following QuickFix's comment ---

There are 3 places where config.xml can show up for iOS development.

  1. Cordova project folder MyApp/config.xml
  2. iOS xcode project folder MyApp/platforms/iOS/MyApp_name/config.xml
  3. iOS www folder MyApp/platforms/iOS/www/config.xml

In my above comment, I meant the config in No. 3 can be safely ignored. And the config.xml in No. 2 is the actual file that is used by Xcode when you issue an IPA file.

The config in No. 1 is only used by Cordova when you run the command cordova build ios or cordova prepare ios or cordova run ios - if you use these commands everytime you build an IPA then your primary config should be the file No. 1 as @QuickFix mentioned, the configs at No. 2 and No. 3 is overwritten each time these cordova commands are run.

With my team, we run cordova build ios only once during the project's entire development life cycle. We make all the changes via Xcode and HTML files are copied directly to MyApp/platforms/iOS/www/.

Note: For Android development, developers should always modify config No. 1 only.

Upvotes: 0

Related Questions