0

I'm trying to debug an application I'm writing. For this specific application, I can't test it while it's connected to the computer. And, in my application, I have all the data I'm trying to check being printed out to the console.

In trying to figure out where to access that data, I learned that the "print()" data doesn't get stored anywhere, it just prints to the console, which only works if the device is attached. (is this correct?)

Now, I read that I need to be using "NSLog" to have the device logs being stored. I have a test NSLog NSLog("TEST") set up in one of my viewdidload() functions and it prints successfully in the console, when my device is connected to the computer.

However, when I go to devices->myiphone->console, the console is being COMPLETELY flooded with random system information. It's literally printing 100 new messages a second. SO I can't use that to check for the logs.

I just updated to the newest version of Xcode, the 8.1 gm.

I'm really struggling with this. All I want to do, is be able to build my application on my phone, use the application on my phone until the problem arises, as it is something I can't keep attached to the computer, and then plug my phone back into my computer and check to see what the application has printed to the console, or logged, whatever, so I can see what is going wrong. How can I do this?

Sorry for the rambling, and thanks so much

Jolaroux
  • 361
  • 1
  • 5
  • 15

1 Answers1

1

What I do in these situations is log to a file on disk. It's easy to write to a file, and it's easy to examine the file after you connect the device to the computer.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • How would I go about creating a file? Where I can access it afterwards. Thanks for answering btw! – Jolaroux Dec 06 '16 at 00:31
  • http://stackoverflow.com/questions/27327067/append-text-or-data-to-text-file-in-swift – matt Dec 06 '16 at 00:35
  • Easy to access afterward, it's right there in the Devices window, which will copy the sandbox to your computer for you. – matt Dec 06 '16 at 00:36
  • Thanks for the tutorial! I used the comment at the bottom of that page, the one that supports swift 3. However, how do I access that file once its created and written to? I don't see anything in the devices window – Jolaroux Dec 06 '16 at 00:44
  • nvm, found it! Thanks so much for your help! – Jolaroux Dec 06 '16 at 00:45