Update Utilities.swift

This commit is contained in:
Sindre Sorhus 2022-12-04 03:12:26 +07:00 committed by GitHub
parent 07426a1948
commit bc26e37585
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -248,10 +248,12 @@ Reference: https://developer.apple.com/library/archive/documentation/System/Conc
internal let dynamicSharedObject = { () -> UnsafeMutableRawPointer in
let imageCount = _dyld_image_count()
for imageIndex in 0..<imageCount {
guard let name = _dyld_get_image_name(imageIndex),
// Use `/SwiftUI` instead of `SwiftUI` to prevent any library named `XXSwiftUI`.
String(cString: name).hasSuffix("/SwiftUI"),
let header = _dyld_get_image_header(imageIndex) else {
guard
let name = _dyld_get_image_name(imageIndex),
// Use `/SwiftUI` instead of `SwiftUI` to prevent any library named `XXSwiftUI`.
String(cString: name).hasSuffix("/SwiftUI"),
let header = _dyld_get_image_header(imageIndex)
else {
continue
}