ionic-team / ionic-app-scripts

App Build Scripts for Ionic Projects
http://ionicframework.com/
MIT License
608 stars 303 forks source link

Platform is not 'cordova' on device #515

Closed ghost closed 7 years ago

ghost commented 7 years ago

With update to 0.0.42, this.platform.is('cordova') is returning false on a device.

I expect it to return true.

Steps to reproduce:

  1. Update ionic-app-scripts to version 0.0.42 or above.
  2. Run any ionic2 app with ionic run (ios or android) --device -lc
  3. Look at the list of platforms returned by the platform instance => console.log(this.platform.platforms());
  4. You will see something like this in ios => ["mobile", "ios", "iphone", "phablet", "mobileweb"] and this in android => ["mobile", "android", "mobileweb"]

Previously it used include "cordova" as well. This is very frustrating especially that it's not documented anywhere.

Here are my dev environment versions:


Your system information:

Cordova CLI: 6.4.0 
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.14
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.46
ios-deploy version: 1.9.0 
ios-sim version: 5.0.12 
OS: macOS Sierra
Node Version: v7.2.0
Xcode version: Xcode 8.1 Build version 8B62
ghost commented 7 years ago

Subsequently, I have noticed that cordova is not available at all.

E.G. this is the error from NativeStorage plugin:

plugin.js:47 Native: tried calling NativeStorage.getItem, but Cordova is not available. Make sure to include cordova.js or run in a device/simulatorcordovaWarn @ plugin.js:47callCordovaPlugin @ plugin.js:126(anonymous function) @ plugin.js:174(anonymous function) @ plugin.js:146t @ polyfills.js:3tryNativePromise @ plugin.js:145getPromise @ plugin.js:167wrapPromise @ plugin.js:173(anonymous function) @ plugin.js:340value @ plugin.js:401(anonymous function) @ global-methods.ts:48t @ polyfills.js:3StorageHandler.get @ global-methods.ts:46MyApp.determineRootPage @ app.component.ts:90MyApp @ app.component.ts:55Wrapper_MyApp @ wrapper.ngfactory.js:7_View_MyApp_Host0.createInternal @ host.ngfactory.js:21AppView.create @ view.js:98DebugAppView.create @ view.js:308ComponentFactory.create @ component_factory.js:157ViewContainerRef_.createComponent @ view_container_ref.js:120IonicApp.ngOnInit @ app-root.js:37Wrapper_IonicApp.detectChangesInternal @ wrapper.ngfactory.js:18_View_IonicApp_Host0.detectChangesInternal @ host.ngfactory.js:30AppView.detectChanges @ view.js:243DebugAppView.detectChanges @ view.js:348ViewRef_.detectChanges @ view_ref.js:136(anonymous function) @ application_ref.js:463ApplicationRef_.tick @ application_ref.js:463ApplicationRef_._loadComponent @ application_ref.js:441ApplicationRef_.bootstrap @ application_ref.js:432(anonymous function) @ application_ref.js:334PlatformRef_._moduleDoBootstrap @ application_ref.js:334(anonymous function) @ application_ref.js:302t.invoke @ polyfills.js:3onInvoke @ ng_zone.js:238t.invoke @ polyfills.js:3e.run @ polyfills.js:3(anonymous function) @ polyfills.js:3t.invokeTask @ polyfills.js:3onInvokeTask @ ng_zone.js:229t.invokeTask @ polyfills.js:3e.runTask @ polyfills.js:3i @ polyfills.js:3

AND this:

http://10.19.7.191:35729/livereload.js?snipver=1 Failed to load resource: the server responded with a status of 404

Also, I'm still getting this in the console, even though the app is running on a device:

lang.js:134 Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.

ghost commented 7 years ago

I just updated to version 0.0.47 and I'm still having the same problem. Platform is not cordova on any device. As a result, none of the cordova plugins and ionic-native packages work.

These are my current dev environment versions:

Your system information:

Cordova CLI: 6.4.0 
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.17
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.47
ios-deploy version: 1.9.0 
ios-sim version: 5.0.13 
OS: macOS Sierra
Node Version: v7.2.0
Xcode version: Xcode 8.1 Build version 8B62

AND

Installed platforms:
  android 6.1.0
  ios 4.3.1
Available platforms: 
  amazon-fireos ~3.6.3 (deprecated)
  blackberry10 ~3.8.0
  browser ~4.1.0
  firefoxos ~3.6.3
  osx ~4.0.1
  webos ~3.7.0
lumitor2 commented 7 years ago

I have same problem after upgrade. There is no true result for this.platform.is('cordova') on Android device. Native plugins are not present in app afterwards :-/ I don't use livereload but common build and copy to device.

Your system information:

Cordova CLI: 6.4.0
Ionic CLI Version: 2.1.17
Ionic App Lib Version: 2.1.7
ios-deploy version: 1.9.0
ios-sim version: 5.0.8
OS: macOS Sierra
Node Version: v6.4.0
Xcode version: Xcode 8.2 Build version 8C38
ghost commented 7 years ago

@danbucholtz @adamdbradley @joewoodhouse Could you please look into this problem? We are still facing this. Thanks a lot.

ghost commented 7 years ago

Okay Finally solved it.

This is very strange though.

I created a new blank project and noticed that the scripts part of package.json looks like this:

    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"

But all of the current update instructions just tell users to put this in the scripts part of package.json:

    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"

Nobody ever mentioned these two first lines:

"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",

This is very frustrating. Ionic team really needs to do a much better job of documenting changes and APIs. Right now it's less than decent and weakest part of the whole framework by a huge gap.