From c4a5fd291bcfcf82a45f9205a3ff5051cc71266f Mon Sep 17 00:00:00 2001 From: David Roman <2538074+davdroman@users.noreply.github.com> Date: Tue, 16 Jul 2024 19:33:14 +0100 Subject: [PATCH] WIP --- Sources/PlatformViewVersion.swift | 2 +- Sources/RuntimeWarnings.swift | 83 ------------------------------- 2 files changed, 1 insertion(+), 84 deletions(-) delete mode 100644 Sources/RuntimeWarnings.swift diff --git a/Sources/PlatformViewVersion.swift b/Sources/PlatformViewVersion.swift index 80b3f0e8..4249887a 100644 --- a/Sources/PlatformViewVersion.swift +++ b/Sources/PlatformViewVersion.swift @@ -72,7 +72,7 @@ public enum PlatformViewVersion Self { let filePath = file.withUTF8Buffer { String(decoding: $0, as: UTF8.self) } let fileName = URL(fileURLWithPath: filePath).lastPathComponent - runtimeWarn( + print( """ If you're seeing this, someone forgot to mark \(fileName):\(line) as unavailable. diff --git a/Sources/RuntimeWarnings.swift b/Sources/RuntimeWarnings.swift deleted file mode 100644 index 39682199..00000000 --- a/Sources/RuntimeWarnings.swift +++ /dev/null @@ -1,83 +0,0 @@ -// MIT License -// -// Copyright (c) 2020 Point-Free, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -import Foundation - -@_transparent -@usableFromInline -@inline(__always) -func runtimeWarn( - _ message: @autoclosure () -> String, - category: String? = "SwiftUIIntrospect" -) { - #if DEBUG - let message = message() - let category = category ?? "Runtime Warning" - #if canImport(os) - os_log( - .fault, - dso: dso, - log: OSLog(subsystem: "com.apple.runtime-issues", category: category), - "%@", - message - ) - #else - fputs("\(formatter.string(from: Date())) [\(category)] \(message)\n", stderr) - #endif - #endif -} - -#if DEBUG - #if canImport(os) - import os - - // NB: Xcode runtime warnings offer a much better experience than traditional assertions and - // breakpoints, but Apple provides no means of creating custom runtime warnings ourselves. - // To work around this, we hook into SwiftUI's runtime issue delivery mechanism, instead. - // - // Feedback filed: https://gist.github.com/stephencelis/a8d06383ed6ccde3e5ef5d1b3ad52bbc - @usableFromInline - nonisolated(unsafe) let dso = { () -> UnsafeMutableRawPointer in - let count = _dyld_image_count() - for i in 0..