We have a project which has some custom plugins. The problem is that when I do
cordova build ios
then the plugins' JS files are not copied over to platforms/ios/www/plugins/, even though the build succeeds without any errors but when I try to install/run the application, then I get undefined error if I access window.plugins
.
Furthermore, the ios.json file in platforms/ios/ doesn't have any entries for the plugins, it is like empty:
{
"prepare_queue": {
"installed": [],
"uninstalled": []
},
"config_munge": {
"files": {}
},
"installed_plugins": {},
"dependent_plugins": {}
}
If I do cordova plugin list
, I can see the list of all the plugins in there. Also the plugins' .h and .m files are copied and present in platforms/ios//Plugins/
These are the contents of my config.xml file.
<?xml version='1.1' encoding='utf-8'?>
<widget id="com.myapp.enterprise.prod" version="0.0.50" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>MyApp</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://cordova.io">
Apache Cordova Team
</author>
<!--
If you do not want any permissions to be added to your app, add the
following tag to your config.xml; you will still have the INTERNET
permission on your app, which PhoneGap requires.
-->
<preference name="permissions" value="none" />
<!-- Customize your app and platform with the preference element. -->
<!-- <preference name="phonegap-version" value="3.4.0" /> -->
<!-- all: current version of PhoneGap -->
<preference name="orientation" value="portrait" />
<!-- all: default means both landscape and portrait are enabled -->
<preference name="target-device" value="universal" />
<!-- all: possible values handset, tablet, or universal -->
<preference name="fullscreen" value="false" />
<!-- all: hides the status bar at the top of the screen -->
<preference name="UIWebViewBounce" value="false" />
<preference name="DisallowOverscroll" value="true" />
<!-- ios: control whether the screen 'bounces' when scrolled beyond the top -->
<preference name="webviewbounce" value="false" />
<!-- ios: control whether the screen 'bounces' when scrolled beyond the top -->
<preference name="prerendered-icon" value="true" />
<!-- ios: if icon is prerendered, iOS will not apply it's gloss to the app's icon on the user's home screen -->
<preference name="stay-in-webview" value="false" />
<!-- ios: external links should open in the default browser, 'true' would use the webview the app lives in -->
<preference name="ios-statusbarstyle" value="black-opaque" />
<!-- ios: black-translucent will appear black because the PhoneGap webview doesn't go beneath the status bar -->
<preference name="detect-data-types" value="true" />
<!-- ios: controls whether data types (such as phone no. and dates) are automatically turned into links by the system -->
<preference name="exit-on-suspend" value="false" />
<!-- ios: if set to true, app will terminate when home button is pressed -->
<preference name="show-splash-screen-spinner" value="true" />
<!-- ios: if set to false, the spinner won't appear on the splash screen during app loading -->
<preference name="auto-hide-splash-screen" value="true" />
<!-- ios: if set to false, the splash screen must be hidden using a JavaScript API -->
<preference name="disable-cursor" value="false" />
<!-- blackberry: prevents a mouse-icon/cursor from being displayed on the app -->
<preference name="android-minSdkVersion" value="7" />
<!-- android: MIN SDK version supported on the target device. MAX version is blank by default. -->
<preference name="KeyboardShrinksView" value="true" />
<preference name="android-installLocation" value="auto" />
<!-- android: app install location. 'auto' will choose. 'internalOnly' is device memory. 'preferExternal' is SDCard. -->
<preference name="KeyboardDisplayRequiresUserAction" value="false" />
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
<preference name="AndroidLaunchMode" value="singleTask" />
<preference name="AutoHideSplashScreen" value="false" />
<preference name="TopActivityIndicator" value="gray" />
<preference name="fadeSplashScreenDuration" value="1" />
<preference name="ShowSplashScreenSpinner" value="false" />
<preference name="SplashScreen" value="splash_je" />
<preference name="SplashScreenDelay" value="10000" />
<content src="index.html" />
<access origin="*" />
</widget>
Also there is no cordova_plugins.js file in the platforms/ios/ folder.
I'm using Mac OS X (El Capitan), Cordova v5.4.0, Xcode v7.1.
There's a bug with iOS plugins in Cordova 5.4.0. Try downgrading Cordova npm install -g [email protected]
or removing and reinstalling your plugin(s) to the project.