0

I'm kind of new to Ios development and still figuring out Xcode.
I have downloaded Xcode 12 beta 3 and I am using SwiftUI.
I was using Xcode 11 and when I wrote print("something") everything went well. after upgrading to 12 beta 3 no print statement is working for me and errors are not shown as well.

I am trying to understand if it something I did wrong in Xcode settings or maybe a bug.
Any help or suggestion will do.

btw, the network request doesn't get to the server. I believe it fails before. the server is working properly. Maybe this info can assist someone.

Thanks a lot in advance!

code sample:

import Foundation

protocol TodosNetworkServiceProtocol {
    func fetchTodos(includingCompleted: Bool) -> [Todo]
    func update(todo: Todo)
    func add(todo: Todo)
    func toggleIsCompleted(for todo: Todo)
}

// final class means it cant be inharited
final class TodosNetworkService: TodosNetworkServiceProtocol {
    func fetchTodos(includingCompleted: Bool) -> [Todo] {
        guard let todosUrl = URL(string: "http://localhost:5000/todos") else { return [] }
        
        URLSession.shared.dataTask(with: todosUrl) { (data, response, error)  in
            // Here it gets into the if but print nothing.
            if error != nil { print(error) }
            
            guard let data = data else { return }
            
            do {
                let response = try JSONDecoder().decode([Todo].self, from: data)
            } catch let err {
                print(err)
                return
            }
            
        }.resume()
        return []
    }
    
    func update(todo: Todo) {
        print("updating todo")
    }
    
    func add(todo: Todo) {
        print("adding todo")
    }
    
    func toggleIsCompleted(for todo: Todo) {
        print("toggeling todo")
    }
}
Avishai Yaniv
  • 420
  • 5
  • 15
  • Does this answer your question? [How to print() to Xcode console in SwiftUI?](https://stackoverflow.com/questions/56517813/how-to-print-to-xcode-console-in-swiftui) – Magnas Aug 04 '20 at 02:03
  • I am using Xcode 12 beta 3 and print works fine. Check if by mistake you added some filter in console log which is filtering out all your print message. [console log filter is in bottum right in Xcode] – Prafulla Aug 04 '20 at 02:11
  • @Magnas Its not the same issue. I know how to print. it just doesn't print. Even the (llb) that some time is there by default, is gone. thanks anyway :) – Avishai Yaniv Aug 04 '20 at 07:27
  • @Prafulla filter is set to All output so I do not believe this is the case.. thanks anyway :) – Avishai Yaniv Aug 04 '20 at 07:27
  • 1
    I observe same for Live Debug Preview only, submitted feedback to Apple. – Asperi Aug 05 '20 at 06:25
  • This is still happening for me on Version 12.0.1 (12A7300). I have submitted the bug to apple. – uplearned.com Sep 30 '20 at 00:21
  • Xcode 12.3, console logs in 'Debug Preview' prints nothing... Running in Simulator prints log just fine. – bauerMusic Dec 26 '20 at 11:09

1 Answers1

0

enter image description here

enter image description here

First enable the debug window to open when ever you run a new build. saves you having to go view > debug area > ... or use the keyboard shortcuts.

Then when the debug area opens it hits a breakpoint. Unselect the breakpoint and the debug area will output your print statements

RyanTCB
  • 7,400
  • 5
  • 42
  • 62