One of the challenges we face as hybrid app developers is determining which configuration settings to use for any given app due to variances in operating systems and browser rendering engines across platforms. The
config.xml file located in the root of your PhoneGap/Cordova projects when you create an app can have a variety of content that can be confusing to developers. The documentation is often less than crystal clear as well.
As a result, I’ve created a new interactive guide to document it and help people understand what each element means as well as the defaults, valid values, required fields and supported platforms for each. You can hover over the elements on the left side in the config.xml file and the details for it will display on the right. You can click the buttons to display the different preferences by platform. I’ll be continuing to update it further as I find more details.
While on the subject of configuration, I also think it’s useful to explain a couple of things going on behind the scenes in terms of configuration content and your apps for at least iOS and Android in case there are some that want to dig in deeper. I will add Windows and other platforms as I learn about them myself.
If you look at the
yourApp/platforms/ios/CordovaLib/ClassesCleaver folder in your project you’ll find classes where your config.xml file is used. It is parsed specifically in the
CDVConfigParser.m class and those properties are then set as needed in the
CDVViewController.m class. You should also be aware of the
<projectName>.plist file that is used by your iOS apps. It’s located in the
../platforms/ios/MyProject/MyProject.plist path (if you open the .xcode project in Xcode then you will find it under the Resources folder) and has settings that affect orientation, icons, splash screens and other properties you may want to modify at some point. Here’s a sample of what it looks like:
You will also find a
CordovaLib folder in the Android platform of your project and the class used for parsing the
config.xml file for Android is
ConfigXmlParser.java. Once parsed, the class that processes the settings is
CordovaActivity.java. You should also be aware of the
<AndroidManifest.xml file used by your Android apps. It’s located in the
../platforms/android/AndroidManifest.xml path and the
Activity element has settings that will affect a number of things. Here’s an example of the defaults:
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="HelloWorld" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize"> <intent-filter android:label="@string/launcher_name"> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
Please feel free to provide any feedback on your own use with these preferences and settings if you have more information to contribute from your own experience. I’ve included the guide below for a preview, but you should open the app here in a new full window for a better experience.