Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
478 views
in Technique[技术] by (71.8m points)

ios8 - How to debug iOS 8 extensions with NSLog?

- (void)viewDidLoad
{
    NSLog(@"%s", __func__);
    // ...
}

in viewDidLoad of an iOS 8 extension. the NSLog outputs nothing in Xcode. NSLog works as usual in the container app though.

How can I get output from debug messages from an extension?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...