Skip to content

Commit

Permalink
Print runtime warning in previews. (#135)
Browse files Browse the repository at this point in the history
* Print runtime warning in previews.

* Use legacy previews
  • Loading branch information
mbrandonw authored Sep 30, 2024
1 parent 27d767d commit d3fd23c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Examples/Examples/ExamplesApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ class ItemsModel {
return lastItem
}
}

struct Previews: PreviewProvider {
static var previews: some View {
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 d3fd23c

Please sign in to comment.