问题
I am using cordova-plugin-statusbar
to customize the appearance of my app's statusbar on iOS. Specifically, I want to change the value of StatusBarOverlaysWebView
to false, so I include the following line in my config.xml
:
<preference name="StatusBarOverlaysWebView" value="false" />
This works great when I test using a local XCode build. When I build on PhoneGap Build, however, the default setting for this value (which is true
) is not overridden.
After considerable head-scratching, I noticed that the order of the preferences in config.xml
is different in the one generated by PhoneGap. In my local build, the following lines from the plugin's plugin.xml
are included before the line overriding the setting:
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" />
<param name="onload" value="true" />
</feature>
<preference name="StatusBarOverlaysWebView" value="true" />
In the config.xml
generated by PhoneGap, however, these lines appear at the very end of the file. I am guessing that "last write wins" and thus the default value is overwriting my custom preference.
Is there some way for me to influence this or is it just a PhoneGap Build bug?
回答1:
@Matthew,
Okay. Thanks for loading your config.xml
. I did read it. I'm not sure you need the extension for NSAppTransportSecurity
. Take them out for now, but save them, just in case.
Here is some more stuff to help clarify.
plugins
- versions of the latest plugins with new spelling; make sure to source=npm
- Plugins Release: June 22, 2015
white-list
- The following blog post corrects misconceptions and misinformation about the white-list, the plugin and CSP. Raymond confesses to making mistake, luckily not may people have made those mistakes. I'm almost sure you have not.
- Important information about Cordova 5
In addition, read the documentation with the plugin (near the top), and not just the white-list guide.
You may need to add:
<allow-navigation (..)>
<allow-intent (..)>
Let me know how it goes. Ohh, and let me see your final config.xml
. TIA
回答2:
@Matthew
your conclusions are incorrect. The order may make a difference, but this is only because you are using a deprecated item.
Here is what you need to know.
- You need to source all you plugins from NPM from now on - starting last week.
- You need to remove ALL references about
<feature (...)>
- see below. - You should start using version for your compiler and plugins - see below.
- You should post your
config.xml
before you make any changes, just in case there are other issues.
All the solutions needed for this fix are in one place: Top Mistakes by Developers new to Cordova/Phonegap The answers cover Cordova/Phonegap both CLI and SDK, as well as Phonegap Build.
On 1.
From the above reference you have hit
11. You need to get your plugins from NPM now.
The rules regarding sourcing your plugins can be rather confusing. The best thing to do is read the blog posts - below. Developers that use CLI can source from github, again see the blog post.
NEW NEW Cordova npm search page
- Cordova Plugins Registry becomes immutable 2015/09/08
- Plugins Release and Moving plugins to npm 2015/04/21
On 2.
This is brand new, I have not had time to add it to the FAQ
<feature>
tags are deprecated. That means they are no longer used.
You can read about it here
I QUOTE
Aside from the
debug-server
feature, the<feature>
tag is essentially deprecated on PhoneGap Build since PhoneGap APIs were pluginized. Permissions are now generally managed by individual plugins, and application manifests and permissions can be modified directly using the config-file element. However for backwards-compatibility, they are still supported and map to device permissions on Android and Windows Phone 8:
In other words, you have a duplicate configuration, and it is doing nothing. Take it out.
On 3.
From the above reference you have hit
- #6 Not setting the "phonegap version" for your compiler
- #7 Not setting "version" for you plugins
For #6 & #7
With the CLI version, if you do not assign a version for your platform OR in ''Phonegap Build'' if you do not set the phonegap-version in config.xml, YOU WILL GET THE LATEST VERSION. If you are lucky, your program just works as expected. If you are not lucky, you'll get a set of cascading errors.
Luckily for all of us, Holly Schinsky has written a nice blog post to explain it all: (NOTE: Holly has not had time to update the article since the move to NPM, use the NPM names, not the names she is using.)
Cordova/PhoneGap Version Confusion
http://devgirl.org/2014/11/07/cordovaphonegap-version-confusion/
I want to repart that part about cascading errors. You and many, many people are at that stage now. In part because of the change of plugin servers (now on NPM) AND because the white-list restrictions have unprepared people scrambling. This part is very very important. Set your verisons now, and in the future upgrade on your time, budget and terms, NOT at the whims of the Cordova team.
On 4.
Please post your config.xml
. I've done this dozens of times and I always pay the price, when people don't post. Thanks.
One last thing, the white-list
requirement. I don't know if you need to use the internet, but if you do read #10 on that FAQ.
Best of Luck
来源:https://stackoverflow.com/questions/33129008/cant-override-preference-using-phonegap-build-order-in-generated-config-xml-is