简体   繁体   中英

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

I've followed the documentation that Apple provides for debugging extensions and I'm still unable to debug an extension, so for example, breakpoints are not being picked up.

I've created a new target for the extension, that created a new scheme and I've configured that scheme to launch the correct app when running my extension.

The extension works fine but debug things like NSLog or breakpoints are not working. I also tried answers like this but they are not working

I'm using Xcode 6 beta 5 and iOS 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM