I have simple SwiftUI.App for MacOS where I use print for debug logs.
As far as I understand I should use os_log for regular "unified" logging, but can use print for my personal debug logs that will be excluded from releases of my app.
import SwiftUI
@main
struct Main: App {
var body: some Scene {
WindowGroup {
Button("Debug") {
print("print")
NSLog("NSLog")
os_log("os_log")
}
}
}
}
Running this app I can see some logs in the Console.app on MacOS. It shows the entries for NSLog and os_log but not the print entry. The Console.app was the only place where I could see logs at all. Actually I want to see all logs on the command line, as I am used to from console applications (e.g., try swift <(echo 'print("success")')).
I start my app using open MyApp.app with the app binary located at ./MyApp.app/Contents/MacOS/MyApp. I also tried opening it with open MyApp.app -W to avoid it getting detached to the background and expecting some console output. However, there was none.
Which leads me to the following questions:
- Where can I see the
printoutput myswift build -c debugbuilds in general (without XCode)? - How can I make this
SwiftUI.Applog to the console when running from the command line?