Skip to content

Commit

Permalink
Print runtime warning in previews.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrandonw committed Sep 26, 2024
1 parent 27d767d commit f508c04
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Examples/Examples/ExamplesApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ class ItemsModel {
return lastItem
}
}

#Preview {
let model = ItemsModel()
Text(model.lastItem?.description ?? "No last item")
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public struct _RuntimeWarningReporter: IssueReporter {
column: UInt
) {
#if canImport(os)
guard ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] != "1"
else {
print("🟣 \(fileID):\(line): \(message() ?? "")")
return
}
let moduleName = String(
Substring("\(fileID)".utf8.prefix(while: { $0 != UTF8.CodeUnit(ascii: "/") }))
)
Expand Down

0 comments on commit f508c04

Please sign in to comment.