Search code examples
swiftwatchkitapple-watchwatch

Log entries on Apple Watch during the day and display later


I'm currently developing an Apple Watch app which uses Background tasks. For some reason, after around 6 hours, I'm having issues with those tasks.

In order to debug this, I'd like my Watch Extension to Log some statements during the day and accessing some kind of log later from my PC. From what I understand reading the documentation, I can only see Apple Watch Log statments when attached to the debugger which is not valid in my case.

Can anyone point me in the direction of what I can do here?

I was actually already thinking about creating a tableview in my watch app and show my custom log, but I'm sure there is an easier way.

Any help is much appreciated!


Solution

  • I don’t understand yet exactly what you are trying to do, but anyway:
    I assume you create some kind of strings on the watch that describe unusual situations.

    On the watch:
    You could create an array of such strings, and append a new string when required. You could then monitor if communication with the iPhone is possible. Either it is possible at the time when a new string is added, or you could receive a notification when it is possible. In both cases, you could send the whole dictionary (depending on its size) as a direct message or as a file to the iPhone.

    On the iPhone:
    When a direct message with this dictionary arrives, simply overwrite a previous version. So, latest when your watch is close to the iPhone, you will have the complete logs on the iPhone app. At appropriate times, you could send them via email to your Mac.

    I am not sure if this a feasible approach for you.