-
-
Notifications
You must be signed in to change notification settings - Fork 9
Angular: Add ionic live reload #8
Comments
@KevinHetzelGFL this works for me: nxext/nx-extensions#773 Just tested with a fresh NX version and fresh app using ios and android with capacitor 5 on a mac. Works for both ios and android. |
@mbeckenbach please tell me which command you use. If i execute |
@KevinHetzelGFL Here is how i do it step by step:
SERVE Target:
RUN Targets: "run": {
"executor": "@nxext/capacitor:cap",
"options": {
"cmd": "run"
},
"configurations": {
"ios": {
"cmd": "run ios -l --external"
},
"android": {
"cmd": "run android -l --external"
}
}
},
|
@KevinHetzelGFL Please note that i tested this on MacOS. I tried to get it running on windows. But windows s*cks as always. |
@KevinHetzelGFL If this really works when deployed to real devices, it opens new options for development & testing. :-D Btw: Works on windows with android too. I just had some issues with Android Studio... |
just to clarify a few things here...
doing it this way will break anything other than a "live reload development run".. the to get around this, you will need to conditionally modify your
in this case, for context, running secondly, the so, at the same time in your application's
you can leave the but then to get the app running with "live reload", you need to:
keep in mind that the app deployed to your device or emulator by this will always look at the configured hope that helps a bit.. |
@andregreeff thank you very much! |
@andregreeff Great! Thank you so much. I just had to modify one line on my mac, adding a fallback if wireless or ethernet up dont work. const serverIp = wirelessIp || ethernetIp || address(); |
@andregreeff Did you ever try to use this approach in combination with ngrok? |
nope, sorry.. I've never used ngrok.
the process of picking which interface to use is a PITA, especially when trying to do so with as little human input as possible. just for reference, my Windows 11 work laptop has both a wireless and wired interface, and I have both VMWare and Fortinet VPN installed, each of which add virtual adapters..
so, querying
but these names can and do vary wildly between different computers, being affected by everything from hardware, host OS, even any additional software that may or may not be installed. so keeping the "desired interface names" as simple and generic as possible, I opted to test the following:
since my PC is connected to my network by Wi-Fi, my network accessible address, and therefore the address I need to use for personally, I often switch between both wired and wireless networks, both at home and at work, so in all of my environments checking the tl;dr: the only truly "safe" way to handle this, is to prompt the user to select an interface to use at runtime.. with all that said, I'm not familiar enough with Nx executors to set up a flow like this.. which I imagine would go along the lines of:
the reason I highlight the extra points with the Angular and Capacitor commands here, is that although they can be executed in parallel with furthermore, even if it does, their output is dumped into the same window, meaning you probably won't even see that anyways, this is just a highlight of the issues I've run into over the past 2 weeks while trying to get this working in my Nx workspace. I'm very far from being an Nx-ninja, but the most reliable way I've found to do this (so far), is the two-terminal approach I described at the end of my previous comment. |
I use the command: cd your app directory |
ok sure, but take note that the but this here is where we run into a few potentially sticky points: most importantly, the apps generated by furthermore, this assumes that you either have NPM workspaces configured in order to take advantage of the root personally I have not had much luck with using NPM's new "workspaces" concept in a Nx workspace, not sure why.. but also this is quite probably why the tl;dr: trying to use Ionic's own "multi-app workspace" feature for this feels like one giant hack. or at the very least, like it would require a crazy number of smaller hacks in order to "just work". |
Trying this in Sept 2024 and I was able to run it without any modification to the "live-reload": {
"executor": "@nxext/capacitor:cap",
"options": {
"cmd": "run --live-reload"
},
"configurations": {
"ios": {
"cmd": "run ios --live-reload"
},
"android": {
"cmd": "run android --live-reload"
}
}
}, then serve the application in one terminal:
and run the native application in the device with:
Thanks for addressing this here! |
@matheo that's interesting, but also confusing.. because unless this changed in a recent version (which I don't think it has), the |
@andregreeff indeed, only the |
no worries, this is still good news though. :) just for the sake of clarity, looks like the seems like the culmination of these two changes is probably what has now resolved this issue now. I guess I can ditch the custom script I created for doing this. happy days! edit: after trying various things for well over an hour now, I still cannot get this to work. however, my project is currently "stuck" on Nx 17 because of third-party Angular package compatibility issues, and as a result @matheo just to confirm, did the project that you tested this in have the latest |
@andregreeff yeah, I'm using the latest versions |
Is your feature request related to a problem? Please describe.
For ionic there are this commands available to run the app with live reload on android or ios:
$ ionic capacitor run ios -l --external
$ ionic capacitor run android -l --external
I realy need it for my ionic app inside nxext Workspace. At the moment I always need to run "nx run [app-name]:sync:android" and "nx run [app-name]:open:android" after changes. It takes a lot of time
The text was updated successfully, but these errors were encountered: