8

I have my iPhone app running on device, I can see logs in xcode.

Then, I what to see logs about what is happening when app restart.

So, I press home button twice -> swipe up to stop my app, then launch the app again. But I can't see any log in xcode anymore.

How can I see logs of my app continuously before & after my app restart in xcode?

==== UPDATE ===

I mean app log. OK, I can narrow my question to: How can I see logs again after I restarted my app? (device is connected to my mac book , I saw app logs in xcode before restarting, but can't find a way to see app logs after I restarted my app).

Leem.fin
  • 40,781
  • 83
  • 202
  • 354
  • If your app is closed you can't obviously see it's logs since it is not running. Maybe you mean system logs? – jalone Jan 14 '16 at 09:55
  • Where are you looking for the logs ? If you are using the debug area, naturally it's going to be empty as the debug session ended with the app being killed. If you are looking at the device console the logs should be there, add details of how you are performing logging in this case. – A-Live Jan 14 '16 at 10:07
  • 1
    My app is not closed only, it closed & start again, I want to see app logs after this restart. – Leem.fin Jan 14 '16 at 10:44
  • WHY someone votes '-1' to my question? A question is too simple to answer for someone doesn't mean you should downvote this question. I tried to find a clear answer on internet before I post the question, but I didn't find a proper answer, then I posted here. What is wrong with this? If mouse hover the downvote button, read what could be downvoted, which downvote condition my question meets? – Leem.fin Jan 14 '16 at 10:54

2 Answers2

1

You can't see logs of an app that is not running. I can tell you this if you're really curious : there is nothing to log anyway. :)

Now you might want one of those things :

System logs : Just go in the Device Manager of XCode (short cut is Shift-Apple-2 I think). It's in the Window Tab, under Devices. Select the device you're running on, then you'll have the logs available there.

This logs everything the device logs, so there will be a LOT of text.

App logs :

Those are the ones you already have, but you seem to clearly want the "restart" logs of your app. There is no such thing as a restart log. What you have is the logs at the start of your app, and the ones at the end. For example, what you logged in your AppDelegate's didBecomeActive or willTerminate (or even didEnterBackground).

You will only see the logs of the didBecomeActive when you actually run the app from XCode (otherwise the debugger is offline). He will start the app as if you tapped on the app icon, so no worries there.

If you decide to kill the app by swiping up, it will log the app delegate, and you'll just be able to browse it in the debugger. You can put a breakpoint if you want to make sure it enters the AppDelegate methods.

But if you want to restart the app again, you'll have to re-run it from Xcode, not manually start it on the phone.

File logging :

Another very easy solution is to log everything on a text file in the Documents directory of your app, you'll then be able to start/quit as much as you want, and let it log on the file. You can later read that file like any other file :)

Gil Sand
  • 5,802
  • 5
  • 36
  • 78
  • 1
    please see my update. Are you saying re-running my app in xcode simulates app user restart app by swiping up & launch app again? – Leem.fin Jan 14 '16 at 10:45
  • 1
    rerunning simulates the user starting the app again. If you manually exit the app before, then yes. But you will lose the debugger while the app is in the "Killed" state. – Gil Sand Jan 14 '16 at 10:50
  • 1
    I have this same problem because I'm trying to debug a crash reporting function -- I see the logs before the app crash, but I'm trying to debug the crash reporter's send of the crash information after the app restart. Restarting from XCode creates a new app id on the phone, which isn't what I want as the crash reporter can't find its crash info any more. Why is this so hard?? – Raman Oct 16 '20 at 02:15
0

In case you want to just show the device logs you may want to take a look at this answer:

https://stackoverflow.com/a/19148654/691977

Community
  • 1
  • 1
jalone
  • 1,953
  • 4
  • 27
  • 46