Skip to content

Commit

Permalink
Use same manner as one that pointfree does
Browse files Browse the repository at this point in the history
  • Loading branch information
fummicc1 committed Dec 18, 2024
1 parent a5f4918 commit 6a5a0e1
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion Sources/GeoHashFramework/RuntimeWarning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,26 @@ import OSLog
enum RuntimeWarning {
static func log(message: StaticString, args: any CVarArg...) {
#if DEBUG
var dso: UnsafeRawPointer?
// ref: https://github.com/pointfreeco/swift-issue-reporting/blob/a3f634d1a409c7979cabc0a71b3f26ffa9fc8af1/Sources/IssueReporting/IssueReporters/RuntimeWarningReporter.swift#L39-L55
let count = _dyld_image_count()
for i in 0..<count {
if let name = _dyld_get_image_name(i) {
let swiftString = String(cString: name)
if swiftString.hasSuffix("/SwiftUI") {
if let header = _dyld_get_image_header(i) {
dso = UnsafeRawPointer(header)
}
}
}
}
guard let dso = dso else {
assertionFailure("Failed to get DSO")
return
}
os_log(
.fault,
dso: #dsohandle,
dso: dso,
log: OSLog(
subsystem: "com.apple.runtime-issues",
category: "ReportRuntimeWarningSample"
Expand Down

0 comments on commit 6a5a0e1

Please sign in to comment.