1/17/2024 0 Comments Ionic livereload android![]() Of course you need to remember to clean the project when you finish and use the device’s files. I we work a little bit we can automate this process and turn it into a trivial operation, but at least now I feel very comfortable. I now that this little hack may looks like something difficult but we need less than a minute to set up the environment and we will save thousand of seconds in the development process. (I’ve got one tearDown.sh file with this commands)Īnd that’s all. We’re going to use de device’s Cordova’s Webkit one, and also if we open our browser it will crash because cordova.js is present now and our local host isn’t a real device.Įach time we need to redeploy the application to the device (new plugin for example) we need to remember to quit the symlinks, and redeploy. We’re using this parameter to not to open our local browser. Now can start the application’s server in our host with: platforms/android/assets/www/cordova_plugins.js (I’ve got one setUp.sh file with this commands) “cordova run android –device” will generate the file to the platform and deploy them to the real device, but as well as we’re going to use this file from our local server (in www), we need to create a set of symlinks in our www folder. But we need to keep in mind that our device will use the cordova.js from our local server, and not from its filesystem. Now we need to deploy the application to our device:Įach time we add/remove one plugin we need to redeploy to the device. Now we change our config.xml to use our local server instead of device’s files: ![]() We can change it manually adding to our index.html (this snippet suppose that your host is 192.168.1.1 if it’s a different one use your local IP address): “ionic serve” do it automatically but it thinks that we’re going to use it with your host browser. If we use on iPhone we only need to change “adroid” to “ios”.įirst of all we need to prepare our index.html to enable auto-reload. In this example I suppose that we’re using one android device. The “slow” phase turns into a “fast” phase. If we change anything in the static files (html, js, css) our app will be reloaded automatically. With this approach we only need to deploy the application to the real device when we want to add/remove one plugin. Use our local server to serve static files instead of build again and again the application with each change.Build the application and install it in the real device.Enable the fs watcher to restart the application when we change one file in the filesystem (inonic serve do it by default).Run a local server with (inoic serve for example).This file is generated when we build the application to a specific platform Even in our LAN (if our android/ios device is the LAN of course)īut, what happens with the plugins? Plugins needs cordova.js file and this file isn’t in www folder. That’s the way to create a “native” app from and existing web application.Īccording to this we can start a local server in our host and use this local web server. We usually do it in config.xmlīut we can change this initial file and use a remote one. ![]() We need to tell to our Cordova application where is the initial index.html. The native one (java code in android and objective-c in ios) and the html/js part. This “slow” phase droves me crazy, so I started to think a little bit about it. Those kind of things doesn’t work in the browser or even with the emulator. If you don’t use plugins you can let this “slow” phase to the end, only to see the behaviour in the device and fix customizations, but ir we use plugins (camera plugin, push notifications or things like that) we really need to test on the real device. That means that I tried to avoid this phase until no remedy. We’ve gone from the “fast” phase to the “slooooow” one. For example when we correct a silly bug we need to run the following command to see the application running on the device:Īnd it takes time (around 10 seconds). IOS one is faster but we need to redeploy the application again and again with each change. OK we’ve got emulators, but they are horrible. With this snippet our application will be reloaded when we add/remove something in our file tree (it runs a filesystem watcher in background).īut as I said before it’s the “fast” phase and sooner or later we will need to run the application in the real device. Ionic also starts a live reload server at and adds the following snippet at the end of our index.html We just type:Īnd ionic starts a local server on port 8100 with our Cordova application, ready to test with the browser (it also opens the browser). Ionic is great and it also provides us a good tool to run a local server. It isn’t different from a “traditional” web developing process. We change something within our code, then we reload our browser and we see the outcome. First we develop the application locally using our browser. Normally when we work with Phonegap/ Cordova applications we work in two phases.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |