Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I debug an iOS app executed in mobile not launched by Xcode?

I am developing an application for iOS in Objective C with Xcode. This application schedules local push notifications every 6 hours and it is crashing when I open the push notifications.

I need to debug the error to solve it. I can have the mobile connected to Xcode, but as the app is executed from local push notification I can't see the error messages on my Xcode debug console, as I haven't launched my app from Xcode.

Is there a way to have the iOS device connected to my Mac and see what error is happening?

I know that I can go to the mobile settings to view logs, but these logs are too ambigous for me aren't giving any error.

like image 956
gabicuesta Avatar asked Dec 14 '22 06:12

gabicuesta


2 Answers

In addition to opening the console log as described by @saurabhgoyal you can tell Xcode to wait for your app to launch and then attach the debugger to it when it does.

Select the scheme you're using to build your app, select edit scheme, and click on the run icon. Then Look for a pair of radio buttons titled "Launch" and select the one with the name "Wait for executable to be launched."

Then when you run your app in Xcode it builds it and installs it on the device but does not launch it.

When your notification fires and the app launches the debugger attaches to your app and you can debug as normal (except that NSLog statements don't print to the debug console any more - an annoyance.)

like image 115
Duncan C Avatar answered Dec 16 '22 20:12

Duncan C


Yes there is a way to see device logs on Mac.

Connect your iOS device to the Mac system using USB

Launch Xcode–>Window–>Devices

Select your device from the left panel

Now you can see the logs on the screen including the background activities.

In order to save the running logs.

Reproduce the issue or start working on your device on a the app you wanted to capture the logs. After the issue is reproduced click on the Save Console icon bottom right corner Xcode screen

For more details please visit this link

Hope this Helps!

like image 36
saurabh goyal Avatar answered Dec 16 '22 19:12

saurabh goyal