I have os_log
statements in my app. With my phone connected to the Mac, when I run the app through XCode, open Console app, those logs are shown. However, when I'm launching the app on its own, those logs don't appear in Console (phone still connected).
Am I missing something very basic? Please help.
I had already done the above steps.
OK.
I just tried this here in my office and it’s working as expected. Specifically:
-
On macOS 13.2.1 using Xcode 14.2 with an iOS 16.3.1 device attached…
-
I launched Console, selected my device on the left, pasted
subsystem:com.example.apple-samplecode.Test727380
into the search field, and clicked “Start streaming”. -
In Xcode, I created a new test project with a button wired up to this code:
import UIKit import OSLog class MyViewController … { let logger = Logger(subsystem: "com.example.apple-samplecode.Test727380", category: "app") func test() { logger.log("Hello Cruel World!") } … other stuff … }
-
With my device selected as the run destination, I chose Product > Run.
-
In the app on the device, I tapped the Test button.
-
In Console, I saw my log message:
type: default time: 09:10:44.044219+0800 process: Test727380 subsystem: com.example.apple-samplecode.Test727380 category: app message: Hello Cruel World!
-
In Xcode, I chose Product > Stop.
-
On the device, I launched the app from the Home screen.
-
I repeated steps 5 and 6 and saw the new log message:
type: default time: 09:11:14.362762+0800 process: Test727380 subsystem: com.example.apple-samplecode.Test727380 category: app message: Hello Cruel World!
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"