Search code examples
iosswiftios-app-extensionios-extensionsios-app-group

How to debug an iOS app extension?


I'm trying to debug an iOS app extension and all I can do is to set breakpoints but it would be nice to be able to print to console.

Is this possible with Xcode 9?

Or at least read it somewhere, maybe a file?

I went to see my device's logs in "devices and simulators" but could't find what I printed from my iOS app extension.


Solution

  • I found a way, it's not perfect but at least i can see what i print now. I used os_log("this is what i will see") function (you have to import os)

    1- i set an environment variable OS_ACTIVITY_MODE = default (not disable) in my extension's scheme

    2- i run build my application in my device

    3- i attach my extension to a process (my app)

    4- you can see your logs in the Console app (Open /Applications/Utilities/Console.app) or opening Windows -> Devices and Simulators to see your devices console.

    The Console app option is the best.