Skip to content

Commit

Permalink
rule out change
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Jun 13, 2024
1 parent 7ed3605 commit e0f7c64
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions Sources/Perception/Internal/RuntimeWarning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,37 @@ func runtimeWarn(
// Feedback filed: https://gist.github.com/stephencelis/a8d06383ed6ccde3e5ef5d1b3ad52bbc
#if swift(>=5.10)
@usableFromInline
nonisolated(unsafe) let dso = getSwiftUIDSO()
nonisolated(unsafe) let dso: UnsafeMutableRawPointer = {
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) {
return UnsafeMutableRawPointer(mutating: UnsafeRawPointer(header))
}
}
}
}
return UnsafeMutableRawPointer(mutating: #dsohandle)
}()
#else
@usableFromInline
let dso = getSwiftUIDSO()
#endif

@_transparent
private func getSwiftUIDSO() -> UnsafeMutableRawPointer {
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) {
return UnsafeMutableRawPointer(mutating: UnsafeRawPointer(header))
let dso = {
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) {
return UnsafeMutableRawPointer(mutating: UnsafeRawPointer(header))
}
}
}
}
}
return UnsafeMutableRawPointer(mutating: #dsohandle)
}
return UnsafeMutableRawPointer(mutating: #dsohandle)
}()
#endif
#else
import Foundation

Expand Down

0 comments on commit e0f7c64

Please sign in to comment.