Hey @wlisac this looks awesome! I’ll definitely have a play around with it. Have you tried your swift base images with the new --live flag on balena push <deviceIP>? I think if swift does incremental compilation, it should speed things up quiet a bit as you wouldn’t rebuild from scratch everytime.
The --live flag sounds promising. I’ll have to give it a try.
Is there some additional documentation for how to use --live besides what’s available on the latest CLI docs?
For example: it sounds like it’ll keep the sources files in sync, but I’m not sure how it would know to trigger a swift build to perform an incremental compilation and to restart the app binary.
So far I’ve been using various other techniques to improve the local device debug loop, mostly by semi-abusing the docker layer cache to cache swift package dependencies / modules.
I’ve also experimented with cross compiling the actual ARM Swift app on macOS and then pushing that to the device via lldb remote debugging (it’s fast and you get breakpoints!). It’s conceptually similar to how iOS apps are built / debugged from macOS and pushed to iOS (ARM) devices. Other folks in the Swift on ARM community are making progress on this front and I plan to explore it more when I have some time.
The local build / test / debug loop is definitely an area of interest for me, so looking forward trying this out.
The livepush readme has a bit more documentation, but it’s still not that fleshed out (it’s on my TODO list!) but I’d be happy to answer any questions you have on livepush (or take feedback too )
@CameronDiver wow! Using --live is pretty awesome, it greatly improves the build / debug loop.
I’ll have to spend more time experimenting with it, but so far
One addition that could be nice is to provide a command / API to manually trigger a “live” rebuild instead of auto-live rebuilding when a source file changes.
When I’m making changes to source files, I often save (or the editor auto-saves) in a state that won’t actually compile.
The ability to make changes to several files, saving as I go, and then manually trigger a “live” build would be great (especially if it could cancel any in-flight live builds).
Hey @wlisac yeah the situation you mention is one of the ones which is keeping livepush in beta for the time being.
Solving it is a little complex, as it involves detecting when a service is restarting constantly, and running a sleep loop while the other code has time to “take over”. The problem is we need to detect this and also detect if it’s a normal running process or in error. I’m thinking of using the return code of the main process and if a non-zero value is detected, we take over the runtime of the container. This of course needs to investigated and tested, but I’ll definitely keep you updated.
In the meantime, it’s possible to avoid this situation with:
|| while true; do sleep 10; done
added to the end of your CMD line, but it’s not ideal.
@CameronDiver I noticed that the live feature is now out of beta – so awesome!
The thing I keep wishing for is what I mentioned above – something like an “on demand” live push:
One addition that could be nice is to provide a command / API to manually trigger a “live” rebuild instead of auto-live rebuilding when a source file changes.
When I’m making changes to source files, I often save (or the editor auto-saves) in a state that won’t actually compile.
The ability to make changes to several files, saving as I go, and then manually trigger a “live” build would be great (especially if it could cancel any in-flight live builds).
Is that something that’s being considered?
Like Shaun mentioned before – live push is so great for compiled languages that support incremental compilation. Love it!
@wlisac I think this is something that I’d have to understand a little better before commenting. If we don’t know which files have changed, this live rebuild would have to re-sync everything, is this what you mean?
I’d be happy to explore other use cases for livepush, as the core principle of livepush is you shouldn’t have to change anything for it to integrate and streamline your development process - so this feedback is super valuable!