Add entry to iOS .plist file via Cordova config.xml
I don't think you can do this via straight config.xml
modification. At least, I didn't see any mention of this in the docs: http://cordova.apache.org/docs/en/3.3.0/config_ref_index.md.html
I think you have to create a plugin, because they can insert plist entries: http://docs.phonegap.com/en/3.3.0/plugin_ref_spec.md.html#Plugin%20Specification
See the 'config-file element' section. Here's a guess as to what the relevant section of the plugin.xml
will look like:
<platform name="ios">
<config-file target="*-Info.plist" parent="CFBundleURLTypes">
<array>
<dict>
<key>GDLibraryMode</key>
<string>GDEnterpriseSimulation</string>
</dict>
</array>
</config-file>
</platform>
Then you can install the plugin: cordova plugin add <your plugin name or file location>
Add fields to info.plist in cordova ios app
After couple of hours of search and few attempts it was actually enough to just add:
<config-file target="*-Info.plist"parent="UIApplicationExitsOnSuspend">
<true/>
</config-file>
(which in my case prevents application from running in the background)
right into config.xml
and nest it inside <platform name="ios">
tag as if it was your plugin. And this setting will be added to *-info.plist
during cordova build ios
without any need to manually install your custom plugin.
Hint: I was firstly mistaken that instead of *
in target="*-Info.plist"
there has to be your app's title, but as it happens there actually has to be a *
symbol and cordova itself will figure out the name of info.plist for you application.
Cordova: Modifying *-Info.plist from plugin.xml
After some further testing and research, I found out how to write the config-file
to work properly. Here is the xml
<config-file target="*-Info.plist" parent="UISupportedExternalAccessoryProtocols">
<array>
<string>jp.star-m.starpro</string>
</array>
</config-file>
Here, I changed the parent name from Supported external accessory protocols
to UISupportedExternalAccessoryProtocols
and remove the <key>
tag and now works as expected.
Ionic v3 Remove Specific Keys from PLIST
These keys are placeholders added by cordova-diagnostic-plugin.
The strings contained within NSLocationAlwaysUsageDescription
and NSLocationAlwaysAndWhenInUseUsageDescription
will only be displayed if you request to use location "Always" at runtime.
Update
To remove those keys from the .plist
, you could use cordova-custom-config. First install it:
cordova plugin add cordova-custom-config
Then add <custom-config-file>
blocks under <platform name="ios">
to delete the unwanted keys:
<platform name="ios">
<custom-config-file parent="NSLocationAlwaysUsageDescription" target="*-Info.plist" mode="delete"/>
<custom-config-file parent="NSLocationAlwaysAndWhenInUseUsageDescription" target="*-Info.plist" mode="delete"/>
Ionic app not showing various permissions in info plist file despite them being in config.xml
Instead of config-file
, you should use edit-config
, which allows the use of the merge
attribute and allows you to specify more than 1 key
<edit-config file="*-Info.plist" mode="merge" target="NSCameraUsageDescription">
<string>Explanation</string>
</edit-config>
<edit-config file="*-Info.plist" mode="merge" target="NSPhotoLibraryUsageDescription">
<string>Explanation</string>
</edit-config>
Related Topics
Prevent Deploying (Disable) Watchkit App with iOS iPhone App in Xcode
Uicollectionview's Cell Disappearing
Passing Data to View Controllers That Are Embedded in Container Views
Issue with Code Autocompletion/Syntax Highlighting in Xcode 4.X
Ios8 Photos Framework: How to Get the Name(Or Filename) of a Phasset
How to Save a Uicolor with Userdefaults
iOS 8 Auto Cell Height - Can't Scroll to Last Row
Reading the Gps Data from the Image Returned by the Camera in iOS Iphone
What Does Error "Thread 1:Exc_Bad_Instruction (Code=Exc_I386_Invop, Subcode=0X0)" Mean
In iOS, How to Create a Button That Is Always on Top of All Other View Controllers
Set Dimensions for Uiimagepickercontroller "Move and Scale" Cropbox
Creating Custom Info Window in Swift with the Google Maps iOS Sdk
How to Detect When Avplayer Video Ends Playing
Application Crashed While Importing Songs from Ipod Library in iPhone for iOS 5.0
Optional Chaining in Swift Closure Where Return Type Has to Be Void
Get an Array of Property Values from an Object Array
iPhone - Draw Transparent Rectangle on Uiview to Reveal View Beneath