11

When I build share extension from Xcode for the real device, Xcode arbitrarily stop debug. But when I launch for simulator, the problem does not occur.

Environment
Xcode 7.1.1
iOS 9.1

Details
When I build share extension, Xcode shows "Finished running MobileSafari.app on iPhone", but Safari does not run. And, The square stop button is arbitrarily gray. So, I launch Safari by myself and choose my extension and post. The debug section does not show anything. Also, URL request is not sent Rails server.

This is the picture when I build the share extension for the real device. enter image description here

I do not know why the real device can not launch share extension at Xcode.
If anyone know the answer about this problem, please tell me.

2 Answers 2

12

Typically you can debug a share extension by going to Debug -> Attach to process or PID and entering the name of your share extension. From there you can open the share extension on your device or simulator and Xcode's debugger should attach and hit breakpoints correctly. However, I've noticed that log messages do not show up when doing this, nor do values populate for variables in the debugger view.

Here's how I got the debugging to work correctly. Run the share extension scheme. When it asks you what app to run, chose 'Photos' (because that's the app your extension will operate in). The Photos app will then launch on your device and you may proceed to use your extension. The debugger in Xcode should then work as expected.

3
  • I gonna check this soon. Sep 12, 2016 at 8:05
  • the second part of your answer should is the correct one. Tested with Xcode 9.2 and debugging works perfectly.
    – pzo
    Jun 5, 2018 at 16:46
  • WOW how intuitive. Why on earth is it not enough to just set a breakpoint? That is beyond my understanding May 10, 2019 at 8:26
0

I encountered this issue as well, though unfortunately I don't know the exact solution, maybe I can offer some information that might be helpful.

I (like you, judging by your screenshot) was using Cocoapods, and Cocoapods was copying resources from the pods into the bundle of the app extension after it was code signed. If memory serves, this was interfering with the code signing in some way, and therefore preventing the app from running under the debugger.

I believe that one of the symptoms of this was that logs appeared in the mac's console (or the device's console, can't remember which) saying something about "blasting onto the device using the old skool[sic] method."

You could confirm that this is the case by removing Cocoapods from your project, or any pods that require resources to be copied after compilation. I believe that the solution was to add some kind of special build phase to the extension project to copy the bundle resources, and disabling whatever Cocoapods uses by default.

As a temporary solution, I believe that deleting your app from the device should allow you to attach the debugger once, on the run where the app is installed for the first time. You might also try deleting derived data for your project.

3
  • Thanks Ben. By your post I noticed that I had not yet reinstalled on device.
    – penlight
    Nov 30, 2015 at 7:55
  • So I tried, and checked whether App Extension was OK. The result was App Extension was running on iPhone and I could see debugger output. I did not delete Cocoapods Library, but I think your answer is reasonable. So I select your answer is best answer.
    – penlight
    Nov 30, 2015 at 8:01
  • The problem rehappened. So, next I remove Cocoapods form project but the problem was not removed.
    – penlight
    Dec 3, 2015 at 3:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.