I'm looking for a way to read the watch's syslog in real-time, similar to the way Device Console or this do it for the iPhone.
It's ok if the phone will be plugged by usb to the computer at the time I'm reading.
At this point I'll even settle for a solution that somehow reads the texts at real-time from Xcode debug console, really (though I will prefer a way to hook in to the watch's syslog in a standard fashion :)..
Thanks!
While I couldn't find any official way to get logs from the device, I did manage to write a hack that does so in real time.
It uses a python GUI automation library to pull the text from the Xcode console window.
Please notice this solution does have it's limitations, as it:
- requires the phone to be connected to the computer via cable
- only contains the logs from your own app, thus it falls short of the tools mentioned earlier.
However, it did solve my problem and I'm publishing the short python code in the hopes that it will help other developers.
import atomac
def get_console():
xcode = atomac.getAppRefByBundleId('com.apple.dt.Xcode')
return xcode.windows()[0].groups()[0].textAreasR()[1]
def run():
console = get_console()
while True:
clog = console.AXValue[-1000:]
last_read = clog.split("\n")[-2]
print last_read
if __name__ == "__main__":
run()
Notice you may have to play with some of the indexes inside get_console() to get the console window in your Xcode setup.
(If you're interested, this hack code was written for a hackathon project, as a way to get fast data from the watch since it couldn't send any UDP packets on WatchOS2 Beta 4 and the official ways of sending data from the watch [such as sendMessageData:replyHandler:errorHandler:
] were too slow for what we needed).
I know this is an old thread, but for anyone who lands on this search, there is way to do this: https://forums.developer.apple.com/thread/94693.
To summarize, load a diagnostic profile onto the watch, (link in the forum post,) then you can use MacOS system console to see the watch messages. Right now I'm having a strange issue where some of the messages I NSLog()
appear and others don't, but you can see the watch messages in real time.