博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ionic:livereload on iOS and android
阅读量:6548 次
发布时间:2019-06-24

本文共 3014 字,大约阅读时间需要 10 分钟。

Ionic - how-to: livereload on iOS and android

Hi, i have seen som discussion about people have problems getting livereload to work and wanted to share how i made it work.

This setup is for a windows pc where you are coding and a mac that are running iOS simulator. I am running the simulator in VMWare but should work on a real mac too. I havent tried on a device yet, but i guess this should work on device too with the correct network setup (i have tested on emulators for ios and android).

First let start out making the Viewer app on the mac. This have to be done only once and can be used to test all your projects. Only time you have to rebuild this is when you are adding new plugins.

All these steps are done on the Mac

1. Create a new starter app with ionic

The template doesnt matter because all code are loaded from ionic serve on the host.

ionic start AppViewer blank --v2 --ts

2. Add this lines to config.xmlin your project

<content src=";/>

<access origin="*"/>
<allow-navigation href="*"/>
You have to replace 192.168.1.1 with the ip of your machine where ionic serve will run - in this case the windows pc.

3. Add all the plugins

you think you are going to use while testing. You can always add more later and just rebuild the viewer app.

Then run your app in emulator:

ionic run ios --target="iPhone-5s"
Target is the emulator you want the app installed on. You can install on multipe and just switch between them on the mac when needed. You can even run sveral simulators at the same time with different iPhone/iPad sim.

To make the viewer app for android just do:

ionic run android

  • Now the viewer app is ready. It wont work yet because the server are
    not set up yet.

    So lets start making the developing environment ready for our viewer

    app.

    All these steps are done on the Windows computer

  • Create your ionic project as usual, add plugins etc

ionic start MyRoxApp blank --v2 --ts

ionic platform add ios
ionic plugin add cordova-plugin-camera
ionic plugin add ...

We are almost there :slight_smile:

Make console.log work

To be able to catch the console.log you have to add this code in the head section of your index.html in your www folder:

3. Make cordova and plugins available

Copy the following from the viewer app's platforms/ios/platform_www on the mac:

cordova_plugins.js, cordova.js + the two folders cordova-js-src and plugins and paste them into your www folder on the developement machine.

Thats it. Now you can do this ionic serve on your developement machine:

ionic serve -a -b -s -c -l --platform ios --nocordovamock

Then start the viewer app on your mac (or device). It should now load your project and automatically update when you save any changes.

When you are ready to publish your app you have to remove the cordova_plugins.js, cordova.js + the two folders cordova-js-src and plugins in your www folder before the final build.


I'm kinda new to ionic and i know this is probably not the best way to do it. Still it works for me and are helping my developement and testing a lot.

转载地址:http://kqyco.baihongyu.com/

你可能感兴趣的文章
[蓝桥] 算法提高 简单加法
查看>>
寻找局部最小值
查看>>
Java单元测试之JUnit篇
查看>>
Redis为什么要把所有数据放到内存中?
查看>>
网络管理中的常见软件和管理维护
查看>>
基于deepin搭建Python2编程环境
查看>>
nasm中org指令的作用
查看>>
UITextField
查看>>
[51nod1236] 序列求和 V3(斐波那契数列)
查看>>
JacaScript arguments
查看>>
windows server 2008 R2 安装
查看>>
[ZJOI2010]贪吃的老鼠
查看>>
linux下怎么卸载自带的JDK和安装想要的JDK
查看>>
Linux Swap扩容
查看>>
网页刷新和重新输入网址的区别
查看>>
linux numastat的理解
查看>>
jQuery Validate自定义各种验证方法(转)
查看>>
Codeforces 847H - Load Testing
查看>>
Spring 定时执行任务
查看>>
jsonp原理
查看>>