How to Debug iOS 8 Extensions With Nslog

How to debug iOS 8 extensions with NSLog?

  1. Debugging works for app extensions.
  2. It works on simulator too.
  3. If your app ext crashes in the simulator, you may find it is not easy to restart your app ext. Restarting your simulator is a quick solution.
  4. Steps to debug an app extension:

    1. Run the container app. In this step, Xcode uploads the container app and app extension to the device or simulator.

    2. Stop the container app. This step is important when you debug in simulator. If you don't do it, Xcode will tell you the simulator is in use.

    3. In Xcode, press menu Debug -> Attach to Process -> By Process Identifer (PID) or Name..., input the app ext's identifier, e.g. com.abc.ContainerApp.MyExtension, to start debugging. Don't forget to set break points. (Update on Aug 25, 2014: you can input MyExtension(your extension's name) directly.)

    4. In the device or simulator, open your app extension.


Updates on Aug 23, 2014:

I found the debugging steps above do not work well on Xcode 6 beta 6 with iOS 8 SDK beta 5 on the simulator.

Solution:

  1. Run your extension in the simulator.
  2. Xcode menu Debug -> Attach to Process -> Choose "MyExtension(your extension's name)" in System section in the menu.

The breakpoints work. But I don't know why logs do not show in the output window.

iOS 8: How to properly setup extension to debug it in Xcode using simulator?

In addition to this answer https://stackoverflow.com/a/24043265/1136433 which says how to view logs of the extension app, in that log you can also check the PID of the extension.

Let's say you have the following NSLog statement:

NSLog(@"Testing");

Execute the extension and in the system.log you will see something like this:

Sep 11 11:13:40 my_machine.local today[5689]: Testing

Where 'today' is the name of the extension you are executing (in my case was a Today Extension) and the '5689' is the extension PID.

So, now you can go to Xcode -> Debug -> Attach to Process and then you can set breakpoints and debug the code.

Hope this can help somebody

KeyboardViewController NSLog IOS 8

You just don't see what is being logged in the debug area of Xcode because the Xcode debugger isn't attached to your extension. Extensions are nearly completely independent from their containing app.

Answered here:
for physical device: https://stackoverflow.com/a/24050325/1453948
for simulator: https://stackoverflow.com/a/24043265/1453948

So in case of simulator go to Simulator menu Debug -> Open System Log

iOS 8 beta 5 Today view extension (widget) stuck at Waiting to Attach

Do not stop & start the debugger while notification windows is open in the simulator. Close the notification window. Stop the debugger. Start it again. Debugging widget in iOS8 is very delicate. You need to do everything in a slow non-agressive way (for now).

Print to console from application extension

Your most reliable choice is to use NSLog for debugging purposes, but println might actually be working in this case. You just need to attach the Xcode debugger to the extension itself.

In my experience, it's a rather buggy process. This answer has more info on the subject. In short, you need to change the target in the Run drop down to your extension, then after you click run you should get a list of things you can run it in.



Related Topics



Leave a reply



Submit