2

When testing my app with connectivity turned off (wifi and cellular off), I am able to catch the error. But, in the Xcode console, I can also see the error messages. My code is not printing these to the console. Are these supposed to appear? Can I ignore them?

Task .<1> HTTP load failed (error code: -1009 [1:50]) 2019-07-10 23:33:42.953046-0700 CodeSample[7157:942572] Task .<1> finished with error - code: -1009

The error codes are picked up here:

`let task = session.dataTask(with: request, completionHandler: { (data: Data?, response: URLResponse?, error: Error?) -> Void in
    if error == nil {
        // do non error stuff
    } else {
        // error handling here
    }`
Ataraxian
  • 303
  • 1
  • 2
  • 5

1 Answers1

2

Those are system logs printed by the OS. You can disable them from your active scheme.

Edit your scheme (Product - Scheme - Edit Scheme) and add an environment variable as shown in the image below.

enter image description here

Neph
  • 1,823
  • 2
  • 31
  • 69
Desdenova
  • 5,326
  • 8
  • 37
  • 45
  • 1
    Thank you, I thought I might have been letting an error get by. Great relief :) – Ataraxian Jul 11 '19 at 16:00
  • There's a long thread about using this specific environment variable [here](https://stackoverflow.com/questions/37800790/hide-strange-unwanted-xcode-logs), the consensus is: Be careful because this might also hide important logs about e.g. layout constraints or permissions. You could try using "default" instead of "disable" but that didn't hide the dataTask logs for me (Xcode 14.2). – Neph Apr 25 '23 at 14:36