diff --git a/Package.swift b/Package.swift index 6bf2bd76..610dd78f 100644 --- a/Package.swift +++ b/Package.swift @@ -17,13 +17,21 @@ func envEnable(_ key: String, default defaultValue: Bool = false) -> Bool { } } -let isXcodeEnv = Context.environment["__CFBundleIdentifier"] == "com.apple.dt.Xcode" -let development = envEnable("OPENSWIFTUI_DEVELOPMENT", default: false) - -// Xcode use clang as linker which supports "-iframework" while SwiftPM use swiftc as linker which supports "-Fsystem" -let systemFrameworkSearchFlag = isXcodeEnv ? "-iframework" : "-Fsystem" +var sharedSwiftSettings: [SwiftSetting] = [ + .enableUpcomingFeature("BareSlashRegexLiterals"), + .enableUpcomingFeature("InternalImportsByDefault"), + .define("OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS"), + .swiftLanguageMode(.v5), +] let releaseVersion = Context.environment["OPENSWIFTUI_TARGET_RELEASE"].flatMap { Int($0) } ?? 2024 +sharedSwiftSettings.append(.define("OPENSWIFTUI_RELEASE_\(releaseVersion)")) +if releaseVersion >= 2021 { + for year in 2021 ... releaseVersion { + sharedSwiftSettings.append(.define("OPENSWIFTUI_SUPPORT_\(year)_API")) + } +} + let platforms: [SupportedPlatform] = switch releaseVersion { case 2024: // iOS 18.0 [ @@ -53,18 +61,15 @@ default: ] } -var sharedSwiftSettings: [SwiftSetting] = [ - .enableUpcomingFeature("BareSlashRegexLiterals"), - .enableUpcomingFeature("InternalImportsByDefault"), - .define("OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS"), - .define("OPENSWIFTUI_RELEASE_\(releaseVersion)"), - .swiftLanguageMode(.v5), -] +let isXcodeEnv = Context.environment["__CFBundleIdentifier"] == "com.apple.dt.Xcode" -if releaseVersion >= 2021 { - for year in 2021 ... releaseVersion { - sharedSwiftSettings.append(.define("OPENSWIFTUI_SUPPORT_\(year)_API")) - } +// Xcode use clang as linker which supports "-iframework" while SwiftPM use swiftc as linker which supports "-Fsystem" +let systemFrameworkSearchFlag = isXcodeEnv ? "-iframework" : "-Fsystem" + +let development = envEnable("OPENSWIFTUI_DEVELOPMENT") + +if development { + sharedSwiftSettings.append(.define("OPENSWIFTUI_DEVELOPMENT")) } let warningsAsErrorsCondition = envEnable("OPENSWIFTUI_WERROR", default: isXcodeEnv && development) diff --git a/Sources/OpenSwiftUI/Accessibility/Modifier/internal/AccessibilityConfigurationModifier.swift b/Sources/OpenSwiftUI/Accessibility/Modifier/internal/AccessibilityConfigurationModifier.swift index d6971dec..e1c7c145 100644 --- a/Sources/OpenSwiftUI/Accessibility/Modifier/internal/AccessibilityConfigurationModifier.swift +++ b/Sources/OpenSwiftUI/Accessibility/Modifier/internal/AccessibilityConfigurationModifier.swift @@ -15,5 +15,5 @@ protocol AccessibilityConfigurationModifier { } extension AccessibilityConfigurationModifier where Configuration == Never { - var configuration: Configuration { fatalError() } + var configuration: Configuration { preconditionFailure("") } } diff --git a/Sources/OpenSwiftUI/App/FinishLaunchTestAction.swift b/Sources/OpenSwiftUI/App/FinishLaunchTestAction.swift index 2219a6a6..92477b9a 100644 --- a/Sources/OpenSwiftUI/App/FinishLaunchTestAction.swift +++ b/Sources/OpenSwiftUI/App/FinishLaunchTestAction.swift @@ -17,7 +17,7 @@ struct FinishLaunchTestAction { #if os(iOS) UIApplication.shared.finishedTest(UIApplication.shared._launchTestName()) #else - fatalError("Unimplemented for other platform") + preconditionFailure("Unimplemented for other platform") #endif } } diff --git a/Sources/OpenSwiftUI/App/LegacyApp.swift b/Sources/OpenSwiftUI/App/LegacyApp.swift index 03b9a7a5..677fe3e3 100644 --- a/Sources/OpenSwiftUI/App/LegacyApp.swift +++ b/Sources/OpenSwiftUI/App/LegacyApp.swift @@ -19,7 +19,7 @@ extension __App { var rootView: V init() { - fatalError("Not a standalone App.") + preconditionFailure("Not a standalone App.") } init(rootView: V) { diff --git a/Sources/OpenSwiftUI/App/OpenSwiftUIApplication.swift b/Sources/OpenSwiftUI/App/OpenSwiftUIApplication.swift index 611bf46b..ee16e1f4 100644 --- a/Sources/OpenSwiftUI/App/OpenSwiftUIApplication.swift +++ b/Sources/OpenSwiftUI/App/OpenSwiftUIApplication.swift @@ -25,7 +25,7 @@ private final class OpenSwiftUIApplication: NSApplication { } required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") + preconditionFailure("init(coder:) has not been implemented") } } #else diff --git a/Sources/OpenSwiftUI/Core/Modifier/SceneModifier/TODO/_SceneModifier.swift b/Sources/OpenSwiftUI/Core/Modifier/SceneModifier/TODO/_SceneModifier.swift index cb99b349..a0e37d23 100644 --- a/Sources/OpenSwiftUI/Core/Modifier/SceneModifier/TODO/_SceneModifier.swift +++ b/Sources/OpenSwiftUI/Core/Modifier/SceneModifier/TODO/_SceneModifier.swift @@ -22,6 +22,6 @@ extension _SceneModifier { extension _SceneModifier where Body == Never { @inline(__always) public func body(content _: SceneContent) -> Body { - fatalError("body() should not be called on \(Self.self)") + preconditionFailure("body() should not be called on \(Self.self)") } } diff --git a/Sources/OpenSwiftUI/Core/Render/DisplayLink.swift b/Sources/OpenSwiftUI/Core/Render/DisplayLink.swift index 93728210..1ab812c7 100644 --- a/Sources/OpenSwiftUI/Core/Render/DisplayLink.swift +++ b/Sources/OpenSwiftUI/Core/Render/DisplayLink.swift @@ -28,11 +28,11 @@ final class DisplayLink: NSObject { #if os(iOS) init(host: AnyUIHostingView, window: UIWindow) { - fatalError("TODO") + preconditionFailure("TODO") } #elseif os(macOS) init(host: AnyUIHostingView, window: NSWindow) { - fatalError("TODO") + preconditionFailure("TODO") } #endif diff --git a/Sources/OpenSwiftUI/EventHandling/Focus/FocusStoreLocation.swift b/Sources/OpenSwiftUI/EventHandling/Focus/FocusStoreLocation.swift index 4a0463b5..458bb7dc 100644 --- a/Sources/OpenSwiftUI/EventHandling/Focus/FocusStoreLocation.swift +++ b/Sources/OpenSwiftUI/EventHandling/Focus/FocusStoreLocation.swift @@ -11,16 +11,16 @@ class FocusStoreLocation: AnyLocation, @unchecked Sendable { } override func get() -> A { - fatalError("TODO") + preconditionFailure("TODO") } override func set(_ value: A, transaction: Transaction) { - fatalError("TODO") + preconditionFailure("TODO") } typealias Value = A - override init() { fatalError() } + override init() { preconditionFailure("") } var store: FocusStore weak var host: GraphHost? diff --git a/Sources/OpenSwiftUI/Integration/Representable/UIKit/UIViewRepresentable.swift b/Sources/OpenSwiftUI/Integration/Representable/UIKit/UIViewRepresentable.swift index 066920ab..1f3a4e7b 100644 --- a/Sources/OpenSwiftUI/Integration/Representable/UIKit/UIViewRepresentable.swift +++ b/Sources/OpenSwiftUI/Integration/Representable/UIKit/UIViewRepresentable.swift @@ -185,11 +185,11 @@ extension UIViewRepresentable { static func _modifyBridgedViewInputs(_ inputs: inout _ViewInputs) {} public static func _makeView(view: _GraphValue, inputs: _ViewInputs) -> _ViewOutputs { - fatalError("TODO") + preconditionFailure("TODO") } public static func _makeViewList(view: _GraphValue, inputs: _ViewListInputs) -> _ViewListOutputs { - fatalError("TODO") + preconditionFailure("TODO") } } diff --git a/Sources/OpenSwiftUI/Integration/UIKit/UIHostingController.swift b/Sources/OpenSwiftUI/Integration/UIKit/UIHostingController.swift index 94bb555f..e6a43c51 100644 --- a/Sources/OpenSwiftUI/Integration/UIKit/UIHostingController.swift +++ b/Sources/OpenSwiftUI/Integration/UIKit/UIHostingController.swift @@ -28,7 +28,7 @@ open class UIHostingController : UIViewController where Content : View } public required init?(coder: NSCoder) { - fatalError("init(coder:) must be implemented in a subclass and call super.init(coder:, rootView:)") + preconditionFailure("init(coder:) must be implemented in a subclass and call super.init(coder:, rootView:)") } func _commonInit() { diff --git a/Sources/OpenSwiftUI/Integration/UIKit/UIHostingView.swift b/Sources/OpenSwiftUI/Integration/UIKit/UIHostingView.swift index 93859a21..7d0eddec 100644 --- a/Sources/OpenSwiftUI/Integration/UIKit/UIHostingView.swift +++ b/Sources/OpenSwiftUI/Integration/UIKit/UIHostingView.swift @@ -41,7 +41,7 @@ open class _UIHostingView: UIView where Content: View { @available(*, unavailable) public required init?(coder _: NSCoder) { - fatalError("init(coder:) has not been implemented") + preconditionFailure("init(coder:) has not been implemented") } deinit { @@ -156,40 +156,40 @@ open class _UIHostingView: UIView where Content: View { extension _UIHostingView: ViewRendererHost { package var renderingPhase: OpenSwiftUICore.ViewRenderingPhase { get { - fatalError("TODO") + preconditionFailure("TODO") } set(newValue) { - fatalError("TODO") + preconditionFailure("TODO") } } package var externalUpdateCount: Int { get { - fatalError("TODO") + preconditionFailure("TODO") } set(newValue) { - fatalError("TODO") + preconditionFailure("TODO") } } package func updateEnvironment() { - fatalError("TODO") + preconditionFailure("TODO") } package func updateSize() { - fatalError("TODO") + preconditionFailure("TODO") } package func updateSafeArea() { - fatalError("TODO") + preconditionFailure("TODO") } package func updateScrollableContainerSize() { - fatalError("TODO") + preconditionFailure("TODO") } package func renderDisplayList(_ list: DisplayList, asynchronously: Bool, time: Time, nextTime: Time, targetTimestamp: Time?, version: DisplayList.Version, maxVersion: DisplayList.Version) -> Time { - fatalError("TODO") + preconditionFailure("TODO") } package func addImplicitPropertiesNeedingUpdate(to _: inout ViewRendererHostProperties) {} @@ -216,7 +216,7 @@ extension _UIHostingView: ViewRendererHost { } package func rootTransform() -> ViewTransform { - fatalError("TODO") + preconditionFailure("TODO") } public func graphDidChange() { diff --git a/Sources/OpenSwiftUI/Scene/Core/Scene.swift b/Sources/OpenSwiftUI/Scene/Core/Scene.swift index ecf54221..b7970107 100644 --- a/Sources/OpenSwiftUI/Scene/Core/Scene.swift +++ b/Sources/OpenSwiftUI/Scene/Core/Scene.swift @@ -16,6 +16,6 @@ extension Never: Scene {} extension Scene { func sceneBodyError() -> Never { - fatalError("body() should not be called on \(Self.self)") + preconditionFailure("body() should not be called on \(Self.self)") } } diff --git a/Sources/OpenSwiftUI/Scene/Core/SceneBuilder.swift b/Sources/OpenSwiftUI/Scene/Core/SceneBuilder.swift index 5f385ad5..db7bde86 100644 --- a/Sources/OpenSwiftUI/Scene/Core/SceneBuilder.swift +++ b/Sources/OpenSwiftUI/Scene/Core/SceneBuilder.swift @@ -44,7 +44,7 @@ extension SceneBuilder { // if #available(iOS 16.1, macOS 13.0, watchOS 9.1, tvOS 16.1, *) { // return LimitedAvailabilityScene(scene) // } else { -// fatalError("Unavailable") +// preconditionFailure("Unavailable") // } // } } diff --git a/Sources/OpenSwiftUI/Scene/WindowGroup.swift b/Sources/OpenSwiftUI/Scene/WindowGroup.swift index 076dd38e..b9c5b566 100644 --- a/Sources/OpenSwiftUI/Scene/WindowGroup.swift +++ b/Sources/OpenSwiftUI/Scene/WindowGroup.swift @@ -47,7 +47,7 @@ public struct WindowGroup: Scene where Content: View { // FIXME public var body: some Scene { - fatalError() + preconditionFailure("") } var title: Text? diff --git a/Sources/OpenSwiftUI/Test/TestApp.swift b/Sources/OpenSwiftUI/Test/TestApp.swift index 415994d1..f2bfab83 100644 --- a/Sources/OpenSwiftUI/Test/TestApp.swift +++ b/Sources/OpenSwiftUI/Test/TestApp.swift @@ -8,10 +8,10 @@ public struct _TestApp { public init() { - fatalError("TODO") + preconditionFailure("TODO") } public func run() -> Never { - fatalError("TODO") + preconditionFailure("TODO") } } @@ -21,12 +21,12 @@ extension _TestApp { var state: StateType init() { - fatalError("TODO") + preconditionFailure("TODO") } var body: some View { state.testView - fatalError("TODO") + preconditionFailure("TODO") } } diff --git a/Sources/OpenSwiftUI/Test/TestIDView.swift b/Sources/OpenSwiftUI/Test/TestIDView.swift index 6d570dce..f643870b 100644 --- a/Sources/OpenSwiftUI/Test/TestIDView.swift +++ b/Sources/OpenSwiftUI/Test/TestIDView.swift @@ -19,7 +19,7 @@ struct TestIDView: PrimitiveView, UnaryView { static func _makeView(view: _GraphValue>, inputs: _ViewInputs) -> _ViewOutputs { // Use IdentifiedView here - fatalError("TODO") + preconditionFailure("TODO") } } diff --git a/Sources/OpenSwiftUI/Test/_Benchmark.swift b/Sources/OpenSwiftUI/Test/_Benchmark.swift index 80ed5457..d3e89dfa 100644 --- a/Sources/OpenSwiftUI/Test/_Benchmark.swift +++ b/Sources/OpenSwiftUI/Test/_Benchmark.swift @@ -5,6 +5,6 @@ public protocol _Benchmark: _Test { extension _TestApp { public func runBenchmarks(_ benchmarks: [_Benchmark]) -> Never { let _ = RootView() - fatalError("TODO") + preconditionFailure("TODO") } } diff --git a/Sources/OpenSwiftUI/Test/_BenchmarkHost.swift b/Sources/OpenSwiftUI/Test/_BenchmarkHost.swift index c9a05757..0c017cc1 100644 --- a/Sources/OpenSwiftUI/Test/_BenchmarkHost.swift +++ b/Sources/OpenSwiftUI/Test/_BenchmarkHost.swift @@ -42,7 +42,7 @@ extension _BenchmarkHost { } return end - begin #else - fatalError("Unsupported Platfrom") + preconditionFailure("Unsupported Platfrom") #endif } diff --git a/Sources/OpenSwiftUI/Test/_PerformanceTest.swift b/Sources/OpenSwiftUI/Test/_PerformanceTest.swift index 9a939152..73b0071f 100644 --- a/Sources/OpenSwiftUI/Test/_PerformanceTest.swift +++ b/Sources/OpenSwiftUI/Test/_PerformanceTest.swift @@ -26,7 +26,7 @@ extension __App { extension _TestApp { public func runPerformanceTests(_ tests: [_PerformanceTest]) -> Never { - fatalError("TODO") + preconditionFailure("TODO") } } @@ -37,7 +37,7 @@ extension _BenchmarkHost { #elseif os(macOS) NSApplication.shared.startedTest(test.name) #else - fatalError("Unimplemented for other platform") + preconditionFailure("Unimplemented for other platform") #endif } @@ -47,7 +47,7 @@ extension _BenchmarkHost { #elseif os(macOS) NSApplication.shared.finishedTest(test.name) #else - fatalError("Unimplemented for other platform") + preconditionFailure("Unimplemented for other platform") #endif } @@ -57,7 +57,7 @@ extension _BenchmarkHost { #elseif os(macOS) NSApplication.shared.failedTest(test.name, withFailure: nil) #else - fatalError("Unimplemented for other platform") + preconditionFailure("Unimplemented for other platform") #endif } } diff --git a/Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/TODO/PlainButtonStyle.swift b/Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/TODO/PlainButtonStyle.swift index d78ffb01..3f26b323 100644 --- a/Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/TODO/PlainButtonStyle.swift +++ b/Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/TODO/PlainButtonStyle.swift @@ -12,7 +12,7 @@ public struct PlainButtonStyle: PrimitiveButtonStyle { public func makeBody(configuration: Configuration) -> some View { // Button(configuration) // .buttonStyle(buttonStyleRepresentation) - fatalError() + preconditionFailure("") } } @@ -35,6 +35,6 @@ private struct PlainButtonStyleBase: ButtonStyle { // configuration.label // } // .opacity(isEnabled ? (configuration.isPressed ? 0.75 : 1.0) : 0.5) - fatalError() + preconditionFailure("") } } diff --git a/Sources/OpenSwiftUI/View/Control/Link/OpenURLActionKey.swift b/Sources/OpenSwiftUI/View/Control/Link/OpenURLActionKey.swift index 31510ccc..1ad6e7d2 100644 --- a/Sources/OpenSwiftUI/View/Control/Link/OpenURLActionKey.swift +++ b/Sources/OpenSwiftUI/View/Control/Link/OpenURLActionKey.swift @@ -26,7 +26,7 @@ struct OpenURLActionKey: EnvironmentKey { completion(error != nil) } #else - fatalError("Unimplemented") + preconditionFailure("Unimplemented") #endif }, isDefault: true @@ -51,7 +51,7 @@ struct OpenSensitiveURLActionKey: EnvironmentKey { } workspace.open(url, configuration: config, completionHandler: completion) #else - fatalError("Unimplemented") + preconditionFailure("Unimplemented") #endif }, isDefault: true diff --git a/Sources/OpenSwiftUI/View/Control/Slider/AnySliderStyle.swift b/Sources/OpenSwiftUI/View/Control/Slider/AnySliderStyle.swift index d174e2c5..0258a83b 100644 --- a/Sources/OpenSwiftUI/View/Control/Slider/AnySliderStyle.swift +++ b/Sources/OpenSwiftUI/View/Control/Slider/AnySliderStyle.swift @@ -13,7 +13,7 @@ protocol SliderStyle { private class AnyStyleBox { func body(configuration _: Slider) -> AnyView { - fatalError("") + preconditionFailure("") } } diff --git a/Sources/OpenSwiftUI/View/Control/Slider/Slider.swift b/Sources/OpenSwiftUI/View/Control/Slider/Slider.swift index 5df910c8..c39db015 100644 --- a/Sources/OpenSwiftUI/View/Control/Slider/Slider.swift +++ b/Sources/OpenSwiftUI/View/Control/Slider/Slider.swift @@ -669,7 +669,7 @@ private struct Normalizing: Projection where Value: Strideable, Value: Ha if let stride { let result = (min.distance(to: max) / stride).rounded(.down) guard result > 0 else { - fatalError("max stride must be positive") + preconditionFailure("max stride must be positive") } length = stride * result maxStrides = result diff --git a/Sources/OpenSwiftUICore/Animation/TODO/AnimatableModifier.swift b/Sources/OpenSwiftUICore/Animation/TODO/AnimatableModifier.swift index 401ab4fa..3f530056 100644 --- a/Sources/OpenSwiftUICore/Animation/TODO/AnimatableModifier.swift +++ b/Sources/OpenSwiftUICore/Animation/TODO/AnimatableModifier.swift @@ -15,7 +15,7 @@ extension AnimatableModifier { } public static func _makeViewList(modifier _: _GraphValue, inputs _: _ViewListInputs, body _: @escaping (_Graph, _ViewListInputs) -> _ViewListOutputs) -> _ViewListOutputs { - fatalError("TODO") + preconditionFailure("TODO") } } @@ -25,6 +25,6 @@ extension ViewModifier where Self: Animatable { } public static func _makeViewList(modifier _: _GraphValue, inputs _: _ViewListInputs, body _: @escaping (_Graph, _ViewListInputs) -> _ViewListOutputs) -> _ViewListOutputs { - fatalError("TODO") + preconditionFailure("TODO") } } diff --git a/Sources/OpenSwiftUICore/Animation/TODO/_AnimatableView.swift b/Sources/OpenSwiftUICore/Animation/TODO/_AnimatableView.swift index 6e6e26bc..2196c97c 100644 --- a/Sources/OpenSwiftUICore/Animation/TODO/_AnimatableView.swift +++ b/Sources/OpenSwiftUICore/Animation/TODO/_AnimatableView.swift @@ -15,7 +15,7 @@ extension _AnimatableView { } public static func _makeViewList(view _: _GraphValue, inputs _: _ViewListInputs) -> _ViewListOutputs { - fatalError("TODO") + preconditionFailure("TODO") } } @@ -25,6 +25,6 @@ extension View where Self: Animatable { } public static func _makeViewList(view _: _GraphValue, inputs _: _ViewListInputs) -> _ViewListOutputs { - fatalError("TODO") + preconditionFailure("TODO") } } diff --git a/Sources/OpenSwiftUICore/Attribute/AsyncAttribute.swift b/Sources/OpenSwiftUICore/Attribute/AsyncAttribute.swift index 233e113b..7027bd60 100644 --- a/Sources/OpenSwiftUICore/Attribute/AsyncAttribute.swift +++ b/Sources/OpenSwiftUICore/Attribute/AsyncAttribute.swift @@ -15,6 +15,6 @@ extension AsyncAttribute { extension Attribute { package func syncMainIfReferences(do body: (Value) -> V) -> V { - fatalError("TODO") + preconditionFailure("TODO") } } diff --git a/Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicProperty.swift b/Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicProperty.swift index b35d24f2..c5208e28 100644 --- a/Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicProperty.swift +++ b/Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicProperty.swift @@ -220,7 +220,7 @@ extension BodyAccessor { ) -> (_GraphValue, _DynamicPropertyBuffer?) { #if canImport(Darwin) guard Body.self != Never.self else { - fatalError("\(Body.self) may not have Body == Never") + preconditionFailure("\(Body.self) may not have Body == Never") } return withUnsafeMutablePointer(to: &inputs) { inputsPointer in func project(flags _: Flags.Type) -> (_GraphValue, _DynamicPropertyBuffer?) { @@ -254,7 +254,7 @@ extension BodyAccessor { } } #else - fatalError("See #39") + preconditionFailure("See #39") #endif } } diff --git a/Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicPropertyBuffer.swift b/Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicPropertyBuffer.swift index 70458c60..c6f1379c 100644 --- a/Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicPropertyBuffer.swift +++ b/Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicPropertyBuffer.swift @@ -272,7 +272,7 @@ private class BoxVTableBase { ptr _: UnsafeMutableRawPointer, from _: UnsafeMutableRawPointer ) { - fatalError() + preconditionFailure("") } class func deinitialize(ptr _: UnsafeMutableRawPointer) {} diff --git a/Sources/OpenSwiftUICore/Data/Environment/CachedEnvironment.swift b/Sources/OpenSwiftUICore/Data/Environment/CachedEnvironment.swift index 66db15c4..99048006 100644 --- a/Sources/OpenSwiftUICore/Data/Environment/CachedEnvironment.swift +++ b/Sources/OpenSwiftUICore/Data/Environment/CachedEnvironment.swift @@ -38,7 +38,7 @@ package struct CachedEnvironment { return value } #else - fatalError("See #39") + preconditionFailure("See #39") #endif } @@ -53,20 +53,20 @@ package struct CachedEnvironment { return attribute } #else - fatalError("See #39") + preconditionFailure("See #39") #endif } func animatedPosition(for inputs: _ViewInputs) -> Attribute { - fatalError("TODO") + preconditionFailure("TODO") } func animatedSize(for inputs: _ViewInputs) -> Attribute { - fatalError("TODO") + preconditionFailure("TODO") } func animatedCGSize(for inputs: _ViewInputs) -> Attribute { - fatalError("TODO") + preconditionFailure("TODO") } // func resolvedForegroundStyle() {} diff --git a/Sources/OpenSwiftUICore/Data/Environment/Environment.swift b/Sources/OpenSwiftUICore/Data/Environment/Environment.swift index 4e1255fc..4086c5f8 100644 --- a/Sources/OpenSwiftUICore/Data/Environment/Environment.swift +++ b/Sources/OpenSwiftUICore/Data/Environment/Environment.swift @@ -232,7 +232,7 @@ public struct Environment: DynamicProperty { @usableFromInline func error() -> Never { - fatalError("Reading Environment<\(Value.self)> outside View.body") + preconditionFailure("Reading Environment<\(Value.self)> outside View.body") } public static func _makeProperty( diff --git a/Sources/OpenSwiftUICore/Data/Location.swift b/Sources/OpenSwiftUICore/Data/Location.swift index 12d89163..5612f07c 100644 --- a/Sources/OpenSwiftUICore/Data/Location.swift +++ b/Sources/OpenSwiftUICore/Data/Location.swift @@ -43,23 +43,23 @@ extension AnyLocationBase: Sendable {} open class AnyLocation: AnyLocationBase, @unchecked Sendable { @_spi(ForOpenSwiftUIOnly) open var wasRead: Bool { - get { fatalError() } - set { fatalError() } + get { preconditionFailure("") } + set { preconditionFailure("") } } @_spi(ForOpenSwiftUIOnly) - open func get() -> Value { fatalError() } + open func get() -> Value { preconditionFailure("") } @_spi(ForOpenSwiftUIOnly) - open func set(_ value: Value, transaction: Transaction) { fatalError() } + open func set(_ value: Value, transaction: Transaction) { preconditionFailure("") } @_spi(ForOpenSwiftUIOnly) open func projecting

(_ projection: P) -> AnyLocation where Value == P.Base, P: Projection { - fatalError() + preconditionFailure("") } @_spi(ForOpenSwiftUIOnly) - open func update() -> (Value, Bool) { fatalError() } + open func update() -> (Value, Bool) { preconditionFailure("") } @_spi(ForOpenSwiftUIOnly) open func isEqual(to other: AnyLocation) -> Bool { self === other } diff --git a/Sources/OpenSwiftUICore/Data/Other/2021/UnsafeAtomicLazy.swift b/Sources/OpenSwiftUICore/Data/Other/2021/UnsafeAtomicLazy.swift index cc91d35d..f5820d16 100644 --- a/Sources/OpenSwiftUICore/Data/Other/2021/UnsafeAtomicLazy.swift +++ b/Sources/OpenSwiftUICore/Data/Other/2021/UnsafeAtomicLazy.swift @@ -18,7 +18,7 @@ package struct UnsafeAtomicLazy: Destroyable { } package func read(_ block: () -> Data) -> Data { - fatalError("TODO") // StrokedPath.boundingRect + preconditionFailure("TODO") // StrokedPath.boundingRect } package func destroy() { diff --git a/Sources/OpenSwiftUICore/Data/Preference/PreferenceList.swift b/Sources/OpenSwiftUICore/Data/Preference/PreferenceList.swift index c91432c7..dd0f94c4 100644 --- a/Sources/OpenSwiftUICore/Data/Preference/PreferenceList.swift +++ b/Sources/OpenSwiftUICore/Data/Preference/PreferenceList.swift @@ -178,11 +178,11 @@ private class PreferenceNode: CustomStringConvertible { return nil } - func find(from _: PreferenceNode?) -> PreferenceNode? { fatalError() } - func combine(from _: PreferenceNode?, next _: PreferenceNode?) -> PreferenceNode? { fatalError() } - func copy(next _: PreferenceNode?) -> PreferenceNode { fatalError() } - class var _includesRemovedValues: Bool { fatalError() } - var description: String { fatalError() } + func find(from _: PreferenceNode?) -> PreferenceNode? { preconditionFailure("") } + func combine(from _: PreferenceNode?, next _: PreferenceNode?) -> PreferenceNode? { preconditionFailure("") } + func copy(next _: PreferenceNode?) -> PreferenceNode { preconditionFailure("") } + class var _includesRemovedValues: Bool { preconditionFailure("") } + var description: String { preconditionFailure("") } } // MARK: - PreferenceNode diff --git a/Sources/OpenSwiftUICore/Data/Preference/PreferencesOutputs.swift b/Sources/OpenSwiftUICore/Data/Preference/PreferencesOutputs.swift index 0b1f316a..1c076035 100644 --- a/Sources/OpenSwiftUICore/Data/Preference/PreferencesOutputs.swift +++ b/Sources/OpenSwiftUICore/Data/Preference/PreferencesOutputs.swift @@ -47,14 +47,14 @@ package struct PreferencesOutputs { let value = self[anyKey: _AnyPreferenceKey.self] return value.map { Attribute(identifier: $0) } #else - fatalError("See #39") + preconditionFailure("See #39") #endif } set { #if canImport(Darwin) self[anyKey: _AnyPreferenceKey.self] = newValue.map { $0.identifier } #else - fatalError("See #39") + preconditionFailure("See #39") #endif } } @@ -63,7 +63,7 @@ package struct PreferencesOutputs { #if canImport(Darwin) preferences.append(KeyValue(key: _AnyPreferenceKey.self, value: value.identifier)) #else - fatalError("See #39") + preconditionFailure("See #39") #endif } diff --git a/Sources/OpenSwiftUICore/Data/Property/PropertyList.swift b/Sources/OpenSwiftUICore/Data/Property/PropertyList.swift index 3f17925a..5ec2ed39 100644 --- a/Sources/OpenSwiftUICore/Data/Property/PropertyList.swift +++ b/Sources/OpenSwiftUICore/Data/Property/PropertyList.swift @@ -81,7 +81,7 @@ package struct PropertyList: CustomStringConvertible { } package subscript(key: K.Type) -> K.Value where K: DerivedPropertyKey { - get { fatalError("TODO") } + get { preconditionFailure("TODO") } } @usableFromInline @@ -126,7 +126,7 @@ package struct PropertyList: CustomStringConvertible { } mutating func merge(_ plist: PropertyList) { - fatalError("TODO") + preconditionFailure("TODO") } } @@ -193,18 +193,18 @@ extension PropertyList { } @usableFromInline - package var description: String { fatalError() } + package var description: String { preconditionFailure("") } func matches(_: Element, ignoredTypes _: inout Set) -> Bool { - fatalError() + preconditionFailure("") } func hasMatchingValue(in _: Unmanaged?) -> Bool { - fatalError() + preconditionFailure("") } func copy(before _: Element?, after _: Element?) -> Element { - fatalError() + preconditionFailure("") } final package func byPrepending(_ element: Element?) -> Element { diff --git a/Sources/OpenSwiftUICore/Data/Protobuf/ProtobufDecoder.swift b/Sources/OpenSwiftUICore/Data/Protobuf/ProtobufDecoder.swift index cc2414ab..d3458195 100644 --- a/Sources/OpenSwiftUICore/Data/Protobuf/ProtobufDecoder.swift +++ b/Sources/OpenSwiftUICore/Data/Protobuf/ProtobufDecoder.swift @@ -471,7 +471,7 @@ extension ProtobufDecoder { /// - Returns: The decodable value resulting from the plist data. func value(fromBinaryPlist data: Data, type: T.Type = T.self) throws -> T where T: Decodable { #if os(WASI) - fatalError("PropertyListDecoder is not avaiable on WASI") + preconditionFailure("PropertyListDecoder is not avaiable on WASI") #else let decoder = PropertyListDecoder() decoder.userInfo = userInfo diff --git a/Sources/OpenSwiftUICore/Data/Protobuf/ProtobufEncoder.swift b/Sources/OpenSwiftUICore/Data/Protobuf/ProtobufEncoder.swift index 357e0e75..304a77eb 100644 --- a/Sources/OpenSwiftUICore/Data/Protobuf/ProtobufEncoder.swift +++ b/Sources/OpenSwiftUICore/Data/Protobuf/ProtobufEncoder.swift @@ -415,7 +415,7 @@ extension ProtobufEncoder { /// - Returns: The encoded binary plist data. func binaryPlistData(for value: T) throws -> Data where T: Encodable { #if os(WASI) - fatalError("PropertyListEncoder is not avaiable on WASI") + preconditionFailure("PropertyListEncoder is not avaiable on WASI") #else let encoder = PropertyListEncoder() encoder.outputFormat = .binary diff --git a/Sources/OpenSwiftUICore/Data/State/StoredLocation.swift b/Sources/OpenSwiftUICore/Data/State/StoredLocation.swift index 7d82be0f..688f5c27 100644 --- a/Sources/OpenSwiftUICore/Data/State/StoredLocation.swift +++ b/Sources/OpenSwiftUICore/Data/State/StoredLocation.swift @@ -55,15 +55,15 @@ package class StoredLocationBase: AnyLocation, Location, @unchecke // MARK: - abstract method fileprivate var isUpdating: Bool { - fatalError("abstract") + preconditionFailure("abstract") } fileprivate func commit(transaction: Transaction, mutation: BeginUpdate) { - fatalError("abstract") + preconditionFailure("abstract") } fileprivate func notifyObservers() { - fatalError("abstract") + preconditionFailure("abstract") } // MARK: - AnyLocation diff --git a/Sources/OpenSwiftUICore/Data/StrongHash.swift b/Sources/OpenSwiftUICore/Data/StrongHash.swift index cbe02884..02d15765 100644 --- a/Sources/OpenSwiftUICore/Data/StrongHash.swift +++ b/Sources/OpenSwiftUICore/Data/StrongHash.swift @@ -150,7 +150,7 @@ package struct StrongHasher { package mutating func combineType(_ type: any Any.Type) { // let signature = OGTypeGetSignature // CC_SHA1_Update(&state, signature, 20) - fatalError("Blocked by latest OGTypeGetSignature") + preconditionFailure("Blocked by latest OGTypeGetSignature") } } diff --git a/Sources/OpenSwiftUICore/Data/Transaction/Transaction.swift b/Sources/OpenSwiftUICore/Data/Transaction/Transaction.swift index 0e7d6e86..2030c8ad 100644 --- a/Sources/OpenSwiftUICore/Data/Transaction/Transaction.swift +++ b/Sources/OpenSwiftUICore/Data/Transaction/Transaction.swift @@ -74,7 +74,7 @@ public struct Transaction { package var isEmpty: Bool { plist.isEmpty } package func mayConcatenate(with other: Transaction) -> Bool { - fatalError("TODO") + preconditionFailure("TODO") } @_transparent @@ -99,11 +99,11 @@ public struct Transaction { } package var current: Transaction { - fatalError("TODO") + preconditionFailure("TODO") } package func forEach(keyType: K.Type, _ body: (K.Value, inout Bool) -> Void) where K: TransactionKey { - fatalError("TODO") + preconditionFailure("TODO") } // FIXME: TO BE REMOVED diff --git a/Sources/OpenSwiftUICore/Data/Update.swift b/Sources/OpenSwiftUICore/Data/Update.swift index 30b19b7f..dd887fa7 100644 --- a/Sources/OpenSwiftUICore/Data/Update.swift +++ b/Sources/OpenSwiftUICore/Data/Update.swift @@ -60,7 +60,7 @@ package enum Update { return } guard isOwner else { - fatalError("OpenSwiftUI is active without having taken its own lock - missing Update.ensure()?") + preconditionFailure("OpenSwiftUI is active without having taken its own lock - missing Update.ensure()?") } } @@ -111,7 +111,7 @@ package enum Update { } } #else - fatalError("See #39") + preconditionFailure("See #39") #endif } #endif @@ -152,7 +152,7 @@ package enum Update { action() let newDepth = depth guard newDepth == oldDepth else { - fatalError("Action caused unbalanced updates.") + preconditionFailure("Action caused unbalanced updates.") } } } diff --git a/Sources/OpenSwiftUICore/Graph/GraphHost.swift b/Sources/OpenSwiftUICore/Graph/GraphHost.swift index db0f8ae2..8f255028 100644 --- a/Sources/OpenSwiftUICore/Graph/GraphHost.swift +++ b/Sources/OpenSwiftUICore/Graph/GraphHost.swift @@ -149,10 +149,10 @@ open class GraphHost: CustomReflectable { } else if let currentSubgraph = Subgraph.current { currentSubgraph.graph.graphHost() } else { - fatalError("no current graph host") + preconditionFailure("no current graph host") } #else - fatalError("Compiler issue on Linux. See #39") + preconditionFailure("Compiler issue on Linux. See #39") #endif } @@ -232,7 +232,7 @@ open class GraphHost: CustomReflectable { return result } #else - fatalError("See #39") + preconditionFailure("See #39") #endif } @@ -282,7 +282,7 @@ extension GraphHost { guard isInstantiated else { return } - fatalError("TODO") + preconditionFailure("TODO") } package final func uninstantiate() { @@ -329,7 +329,7 @@ extension GraphHost { } package final func updateRemovedState() { - fatalError("TODO") + preconditionFailure("TODO") } // MARK: - GraphHost + Transaction @@ -341,7 +341,7 @@ extension GraphHost { style: _GraphMutation_Style = .deferred, mayDeferUpdate: Bool = true ) where T: GraphMutation { - fatalError("TODO") + preconditionFailure("TODO") } package final func asyncTransaction( @@ -392,30 +392,30 @@ extension GraphHost { pendingTransactions = [] for _ in transactions { instantiateIfNeeded() - fatalError("TODO") + preconditionFailure("TODO") } graphDelegate?.graphDidChange() mayDeferUpdate = true } package final func runTransaction(_ transaction: Transaction? = nil, do body: () -> Void) { - fatalError("TODO") + preconditionFailure("TODO") } package final func runTransaction() { - fatalError("TODO") + preconditionFailure("TODO") } package final var needsTransaction: Bool { - fatalError("TODO") + preconditionFailure("TODO") } package final func startTransactionUpdate() { - fatalError("TODO") + preconditionFailure("TODO") } package final func finishTransactionUpdate(in subgraph: Subgraph, postUpdate: (_ again: Bool) -> Void = { _ in }) { - fatalError("TODO") + preconditionFailure("TODO") } } @@ -424,7 +424,7 @@ extension GraphHost { private static var pendingGlobalTransactions: [GlobalTransaction] = [] private static func flushGlobalTransactions() { - fatalError("TODO") + preconditionFailure("TODO") } package static func globalTransaction( @@ -433,7 +433,7 @@ extension GraphHost { mutation: T, hostProvider: any TransactionHostProvider ) where T: GraphMutation { - fatalError("TODO") + preconditionFailure("TODO") } } @@ -596,5 +596,5 @@ private var blockedGraphHosts: [Unmanaged] = [] private let waitingForPreviewThunks = EnvironmentHelper.bool(for: "XCODE_RUNNING_FOR_PREVIEWS") public func __previewThunksHaveFinishedLoading() { - fatalError("TODO") + preconditionFailure("TODO") } diff --git a/Sources/OpenSwiftUICore/Graph/GraphInputs.swift b/Sources/OpenSwiftUICore/Graph/GraphInputs.swift index 4b3bf686..48d16cb8 100644 --- a/Sources/OpenSwiftUICore/Graph/GraphInputs.swift +++ b/Sources/OpenSwiftUICore/Graph/GraphInputs.swift @@ -22,7 +22,7 @@ extension GraphInput { } package static func makeReusable(indirectMap: IndirectAttributeMap, value: inout Value) { - fatalError("Reusable graph inputs must implement all reuse methods.") + preconditionFailure("Reusable graph inputs must implement all reuse methods.") } @inlinable @@ -103,7 +103,7 @@ public struct _GraphInputs { transaction: Attribute(identifier: .nil) ) #else - fatalError("See #39") + preconditionFailure("See #39") #endif } @@ -152,15 +152,15 @@ public struct _GraphInputs { } package mutating func `import`(_ src: _GraphInputs) { - fatalError("TODO") + preconditionFailure("TODO") } package mutating func merge(_ src: _GraphInputs) { - fatalError("TODO") + preconditionFailure("TODO") } package mutating func merge(_ src: _GraphInputs, ignoringPhase: Bool) { - fatalError("TODO") + preconditionFailure("TODO") } package func mapEnvironment(_ keyPath: KeyPath) -> Attribute { @@ -169,11 +169,11 @@ public struct _GraphInputs { package mutating func copyCaches() { // Blocked by cachedEnvironment - fatalError("TODO") + preconditionFailure("TODO") } package mutating func resetCaches() { // Blocked cachedEnvironment - fatalError("TODO") + preconditionFailure("TODO") } package mutating func append(_ newValue: U, to _: T.Type) where T: GraphInput, T.Value == Stack { @@ -306,6 +306,6 @@ extension _GraphInputs { // var newInputs = self // newInputs.cachedEnvironment = MutableBox(cachedEnvironment.wrappedValue) // return newInputs - fatalError("TO BE REMOVED") + preconditionFailure("TO BE REMOVED") } } diff --git a/Sources/OpenSwiftUICore/Graphic/Color/Color.swift b/Sources/OpenSwiftUICore/Graphic/Color/Color.swift index 59f16bac..b2c00a9f 100644 --- a/Sources/OpenSwiftUICore/Graphic/Color/Color.swift +++ b/Sources/OpenSwiftUICore/Graphic/Color/Color.swift @@ -112,7 +112,7 @@ extension Color { } package func HSBToRGB(hue: Double, saturation: Double, brightness: Double) -> (red: Double, green: Double, blue: Double) { - fatalError("TODO") + preconditionFailure("TODO") } @@ -167,7 +167,7 @@ extension ColorProvider { package var kitColor: AnyObject? { nil } package var colorDescription: String { String(describing: self) } package func opacity(at level: Int, environment: EnvironmentValues) -> Float { - fatalError("TODO") + preconditionFailure("TODO") } } diff --git a/Sources/OpenSwiftUICore/Graphic/Color/ColorMatrix.swift b/Sources/OpenSwiftUICore/Graphic/Color/ColorMatrix.swift index 3bdeb8f2..27465937 100644 --- a/Sources/OpenSwiftUICore/Graphic/Color/ColorMatrix.swift +++ b/Sources/OpenSwiftUICore/Graphic/Color/ColorMatrix.swift @@ -57,7 +57,7 @@ public struct _ColorMatrix: Equatable, Codable { public init(color: Color, in environment: EnvironmentValues) { // Blocked by Color - fatalError("TODO") + preconditionFailure("TODO") } package init(_ m: ColorMatrix) { @@ -170,7 +170,7 @@ extension _ColorMatrix { } package init?(_ filter: GraphicsFilter, premultiplied: Bool = false) { - fatalError("TODO") + preconditionFailure("TODO") } package init(colorMultiply c: Color.Resolved, premultiplied: Bool = false) { diff --git a/Sources/OpenSwiftUICore/Graphic/Color/ColorResolved.swift b/Sources/OpenSwiftUICore/Graphic/Color/ColorResolved.swift index a5bb2652..8347f66c 100644 --- a/Sources/OpenSwiftUICore/Graphic/Color/ColorResolved.swift +++ b/Sources/OpenSwiftUICore/Graphic/Color/ColorResolved.swift @@ -30,14 +30,14 @@ extension Color { } // package func over(_ s: Resolved) -> Color.Resolved { -// fatalError("TODO") +// preconditionFailure("TODO") // } } package struct ResolvedVibrant: Equatable { package var scale: Float package var bias: (Float, Float, Float) - // package var colorMatrix: _ColorMatrix { fatalError("TODO") } + // package var colorMatrix: _ColorMatrix { preconditionFailure("TODO") } package static func == (lhs: ResolvedVibrant, rhs: ResolvedVibrant) -> Bool { lhs.scale == rhs.scale && lhs.bias == rhs.bias @@ -64,7 +64,7 @@ extension Color.Resolved/*: ResolvedPaint*/ { extension Color.Resolved: ShapeStyle/*, PrimitiveShapeStyle*/ { public func _apply(to shape: inout _ShapeStyle_Shape) { - fatalError("TODO") + preconditionFailure("TODO") } public typealias Resolved = Never @@ -94,7 +94,7 @@ extension Color.Resolved : Animatable { get { if Self.legacyInterpolation { // ResolvedGradient.Color.Space.convertIn(self) - fatalError("TODO") + preconditionFailure("TODO") } else { let factor: Float = 128.0 return AnimatablePair(linearRed * factor, AnimatablePair(linearGreen * factor, AnimatablePair(linearBlue * factor, opacity * factor))) @@ -105,7 +105,7 @@ extension Color.Resolved : Animatable { let factor: Float = 0.0078125 if Self.legacyInterpolation { // ResolvedGradient.Color.Space.convertOut(self) - fatalError("TODO") + preconditionFailure("TODO") } else { linearRed = newValue.first * factor linearGreen = newValue.second.first * factor diff --git a/Sources/OpenSwiftUICore/Graphic/ResolvedPaint.swift b/Sources/OpenSwiftUICore/Graphic/ResolvedPaint.swift index 5c3b1629..0983a8d8 100644 --- a/Sources/OpenSwiftUICore/Graphic/ResolvedPaint.swift +++ b/Sources/OpenSwiftUICore/Graphic/ResolvedPaint.swift @@ -7,7 +7,7 @@ package class AnyResolvedPaint: Equatable { package static func == (lhs: AnyResolvedPaint, rhs: AnyResolvedPaint) -> Bool { - fatalError("TODO") + preconditionFailure("TODO") } } diff --git a/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/Stack/HVStack.swift b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/Stack/HVStack.swift index c78ff394..4c44f1ed 100644 --- a/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/Stack/HVStack.swift +++ b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/Stack/HVStack.swift @@ -18,6 +18,6 @@ public struct HStack: PrimitiveView { var _tree: _VariadicView.Tree<_HStackLayout, Content> public static func _makeView(view _: _GraphValue>, inputs _: _ViewInputs) -> _ViewOutputs { - fatalError("TODO") + preconditionFailure("TODO") } } diff --git a/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/LayoutComputer.swift b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/LayoutComputer.swift index 607e3c15..d496f549 100644 --- a/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/LayoutComputer.swift +++ b/Sources/OpenSwiftUICore/Layout/LayoutFundamentals/internal/LayoutComputer.swift @@ -30,7 +30,7 @@ extension LayoutComputer { func layoutPriority() -> Double { .zero } func ignoresAutomaticPadding() -> Bool { false } func requiresSpacingProjection() -> Bool { false } - func spacing() -> Spacing { fatalError() } + func spacing() -> Spacing { preconditionFailure("") } func lengthThatFits(_ size: _ProposedSize, in axis: Axis) -> CGFloat { let result = sizeThatFits(size) return switch axis { @@ -39,8 +39,8 @@ extension LayoutComputer { } } - func sizeThatFits(_: _ProposedSize) -> CGSize { fatalError() } - func childGeometries(at _: ViewSize, origin _: CGPoint) -> [ViewGeometry] { fatalError() } + func sizeThatFits(_: _ProposedSize) -> CGSize { preconditionFailure("") } + func childGeometries(at _: ViewSize, origin _: CGPoint) -> [ViewGeometry] { preconditionFailure("") } func explicitAlignment(_: AlignmentKey, at _: ViewSize) -> CGFloat? { nil } } } diff --git a/Sources/OpenSwiftUICore/Log/Logging.swift b/Sources/OpenSwiftUICore/Log/Logging.swift index 63bbebb1..8c605f5b 100644 --- a/Sources/OpenSwiftUICore/Log/Logging.swift +++ b/Sources/OpenSwiftUICore/Log/Logging.swift @@ -165,13 +165,18 @@ extension Log: Sendable {} @_transparent package func precondition(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String, file: StaticString = #fileID, line: UInt = #line) { guard condition() else { - Swift.preconditionFailure(message(), file: file, line: line) + preconditionFailure(message(), file: file, line: line) } } @_transparent package func preconditionFailure(_ message: @autoclosure () -> String, file: StaticString, line: UInt) -> Never { - Swift.preconditionFailure(message(), file: file, line: line) + #if DEBUG && OPENSWIFTUI_DEVELOPMENT + if message() == "TODO" { + print("💣 Hit unimplemented part of OpenSwiftUI at \(file):\(line).\nConsider adding a plain implementation to avoid crash.") + } + #endif + Swift.fatalError(message(), file: file, line: line) } @_transparent diff --git a/Sources/OpenSwiftUICore/Modifier/AppearanceActionModifier.swift b/Sources/OpenSwiftUICore/Modifier/AppearanceActionModifier.swift index ff027d51..047def13 100644 --- a/Sources/OpenSwiftUICore/Modifier/AppearanceActionModifier.swift +++ b/Sources/OpenSwiftUICore/Modifier/AppearanceActionModifier.swift @@ -38,7 +38,7 @@ public struct _AppearanceActionModifier: PrimitiveViewModifier { inputs: _ViewListInputs, body: @escaping (_Graph, _ViewListInputs) -> _ViewListOutputs ) -> _ViewListOutputs { - fatalError("TODO") + preconditionFailure("TODO") } } @@ -91,7 +91,7 @@ extension AppearanceEffect: StatefulRule { lastValue = modifier appeared() #else - fatalError("See #39") + preconditionFailure("See #39") #endif } } diff --git a/Sources/OpenSwiftUICore/Modifier/ViewModifier/CustomViewModifier.swift b/Sources/OpenSwiftUICore/Modifier/ViewModifier/CustomViewModifier.swift index d0ca6df3..c4fe047c 100644 --- a/Sources/OpenSwiftUICore/Modifier/ViewModifier/CustomViewModifier.swift +++ b/Sources/OpenSwiftUICore/Modifier/ViewModifier/CustomViewModifier.swift @@ -39,14 +39,14 @@ extension ViewModifier { inputs: _ViewListInputs, body: @escaping (_Graph, _ViewListInputs) -> _ViewListOutputs ) -> _ViewListOutputs { - fatalError("TODO") + preconditionFailure("TODO") } static func viewListCount( inputs: _ViewListCountInputs, body: (_ViewListCountInputs) -> Int? ) -> Int? { - fatalError("TODO") + preconditionFailure("TODO") } private static func makeBody( @@ -60,7 +60,7 @@ extension ViewModifier { let accessor = ModifierBodyAccessor() return accessor.makeBody(container: modifier, inputs: &inputs, fields: fields) default: - fatalError("view modifiers must be value types: \(Self.self)") + preconditionFailure("view modifiers must be value types: \(Self.self)") } } } @@ -95,7 +95,7 @@ public struct _ViewModifier_Content: PrimitiveView { case let .view(makeViewBody): return makeViewBody(_Graph(), inputs) case let .list(makeViewListBody): - fatalError("TODO: \(String(describing: makeViewListBody))") + preconditionFailure("TODO: \(String(describing: makeViewListBody))") } } @@ -103,14 +103,14 @@ public struct _ViewModifier_Content: PrimitiveView { view: _GraphValue, inputs: _ViewListInputs ) -> _ViewListOutputs { - fatalError("TODO") + preconditionFailure("TODO") } public static func _viewListCount( inputs: _ViewListCountInputs, body: (_ViewListCountInputs) -> Int? ) -> Int? { - fatalError("TODO") + preconditionFailure("TODO") } } diff --git a/Sources/OpenSwiftUICore/Modifier/ViewModifier/ViewModifier.swift b/Sources/OpenSwiftUICore/Modifier/ViewModifier/ViewModifier.swift index bc0fbaa1..bc7fe379 100644 --- a/Sources/OpenSwiftUICore/Modifier/ViewModifier/ViewModifier.swift +++ b/Sources/OpenSwiftUICore/Modifier/ViewModifier/ViewModifier.swift @@ -160,6 +160,6 @@ extension ViewModifier where Self: _GraphInputsModifier, Body == Never { extension ViewModifier { func bodyError() -> Never { - fatalError("body() should not be called on \(Self.self)") + preconditionFailure("body() should not be called on \(Self.self)") } } diff --git a/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.GraphicsRenderer.swift b/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.GraphicsRenderer.swift index 22aefc1c..58e736ad 100644 --- a/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.GraphicsRenderer.swift +++ b/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.GraphicsRenderer.swift @@ -42,31 +42,31 @@ extension DisplayList { package var platformViewMode: DisplayList.GraphicsRenderer.PlatformViewMode package init(platformViewMode: DisplayList.GraphicsRenderer.PlatformViewMode) { - fatalError("TODO") + preconditionFailure("TODO") } package func render(at time: Time, do body: () -> Void) { - fatalError("TODO") + preconditionFailure("TODO") } package func renderDisplayList(_ list: DisplayList, at time: Time, in ctx: inout GraphicsContext) { - fatalError("TODO") + preconditionFailure("TODO") } package func render(list: DisplayList, in ctx: inout GraphicsContext) { - fatalError("TODO") + preconditionFailure("TODO") } package func render(item: DisplayList.Item, in ctx: inout GraphicsContext) { - fatalError("TODO") + preconditionFailure("TODO") } package func drawImplicitLayer(in ctx: inout GraphicsContext, content: (inout GraphicsContext) -> Void) { - fatalError("TODO") + preconditionFailure("TODO") } package func renderPlatformView(_ view: AnyObject?, in ctx: GraphicsContext, size: CGSize, viewType: any Any.Type) { - fatalError("TODO") + preconditionFailure("TODO") } } } diff --git a/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.ViewRenderer.swift b/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.ViewRenderer.swift index 6bace908..29cc3cd3 100644 --- a/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.ViewRenderer.swift +++ b/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.ViewRenderer.swift @@ -129,7 +129,7 @@ extension DisplayList { var lastContentsScale: CGFloat init(platform: DisplayList.ViewUpdater.Platform, host: ViewRendererHost?, rootView: AnyObject, options: _RendererConfiguration.RasterizationOptions) { - fatalError() + preconditionFailure("") } var exportedObject: AnyObject? { @@ -137,19 +137,19 @@ extension DisplayList { } func render(rootView: AnyObject, from list: DisplayList, time: Time, version: DisplayList.Version, maxVersion: DisplayList.Version, environment: DisplayList.ViewRenderer.Environment) -> Time { - fatalError("TODO") + preconditionFailure("TODO") } func renderAsync(to list: DisplayList, time: Time, targetTimestamp: Time?, version: DisplayList.Version, maxVersion: DisplayList.Version) -> Time? { - fatalError("TODO") + preconditionFailure("TODO") } func destroy(rootView: AnyObject) { - fatalError("TODO") + preconditionFailure("TODO") } var viewCacheIsEmpty: Bool { - fatalError("TODO") + preconditionFailure("TODO") } } } diff --git a/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.ViewUpdater.swift b/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.ViewUpdater.swift index 76adaf0c..38778ee7 100644 --- a/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.ViewUpdater.swift +++ b/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.ViewUpdater.swift @@ -9,7 +9,7 @@ extension DisplayList { // FIXME final package class ViewUpdater: ViewRendererBase { init() { - fatalError() + preconditionFailure("") } init(platform: Platform, exportedObject: AnyObject? = nil, viewCacheIsEmpty: Bool) { diff --git a/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.swift b/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.swift index b9b07f37..38788f90 100644 --- a/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.swift +++ b/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.swift @@ -89,11 +89,11 @@ package struct DisplayList: Equatable { } package mutating func append(_ item: Item) { - fatalError("TODO") + preconditionFailure("TODO") } package mutating func append(contentsOf other: DisplayList) { - fatalError("TODO") + preconditionFailure("TODO") } } @@ -365,16 +365,16 @@ extension DisplayList { } package mutating func skip(list: DisplayList) { - fatalError("TODO") + preconditionFailure("TODO") } package mutating func skip(item: Item) { - fatalError("TODO") + preconditionFailure("TODO") } package mutating func skip(effect: Effect) { - fatalError("TODO") + preconditionFailure("TODO") } package func assertItem(_ item: Item) {} diff --git a/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList_StableIdentity.swift b/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList_StableIdentity.swift index 5f73b45c..bab24361 100644 --- a/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList_StableIdentity.swift +++ b/Sources/OpenSwiftUICore/Render/DisplayList/DisplayList_StableIdentity.swift @@ -41,7 +41,7 @@ final package class _DisplayList_StableIdentityRoot { if let map { return map[index] } else { - fatalError("TODO") + preconditionFailure("TODO") } } } @@ -81,17 +81,17 @@ extension _DisplayList_StableIdentity: ProtobufMessage { } package init(from decoder: inout ProtobufDecoder) throws { - fatalError("TODO") + preconditionFailure("TODO") } } extension _DisplayList_StableIdentityMap: ProtobufMessage { package func encode(to encoder: inout ProtobufEncoder) throws { - fatalError("TODO") + preconditionFailure("TODO") } package init(from decoder: inout ProtobufDecoder) throws { - fatalError("TODO") + preconditionFailure("TODO") } } @@ -145,7 +145,7 @@ extension _GraphInputs { package func makeStableTypeData(_ type: any Any.Type) -> StrongHash { // OGTypeGetSignature - fatalError("TODO") + preconditionFailure("TODO") } package func makeStableIDData(from id: ID) -> StrongHash? { diff --git a/Sources/OpenSwiftUICore/Render/PlatformViewDefinition.swift b/Sources/OpenSwiftUICore/Render/PlatformViewDefinition.swift index cc8888e3..f1046e97 100644 --- a/Sources/OpenSwiftUICore/Render/PlatformViewDefinition.swift +++ b/Sources/OpenSwiftUICore/Render/PlatformViewDefinition.swift @@ -48,18 +48,18 @@ open class PlatformViewDefinition: @unchecked Sendable { } open class var system: PlatformViewDefinition.System { .init(base: .swiftUIView) } - open class func makeView(kind: PlatformViewDefinition.ViewKind) -> AnyObject { fatalError() } + open class func makeView(kind: PlatformViewDefinition.ViewKind) -> AnyObject { preconditionFailure("") } #if canImport(Darwin) - open class func makeLayerView(type: CALayer.Type, kind: PlatformViewDefinition.ViewKind) -> AnyObject { fatalError() } + open class func makeLayerView(type: CALayer.Type, kind: PlatformViewDefinition.ViewKind) -> AnyObject { preconditionFailure("") } #endif - open class func makePlatformView(view: AnyObject, kind: PlatformViewDefinition.ViewKind) { fatalError() } - // open class func makeDrawingView(options: PlatformDrawableOptions) -> any PlatformDrawable { fatalError() } - open class func setPath(_ path: Path, shapeView: AnyObject) { fatalError() } - open class func setProjectionTransform(_ transform: ProjectionTransform, projectionView: AnyObject) { fatalError() } - open class func getRBLayer(drawingView: AnyObject) -> AnyObject? { fatalError() } - open class func setIgnoresEvents(_ state: Bool, of view: AnyObject) { fatalError() } - open class func setAllowsWindowActivationEvents(_ value: Bool?, for view: AnyObject) { fatalError() } - open class func setHitTestsAsOpaque(_ value: Bool, for view: AnyObject) { fatalError() } + open class func makePlatformView(view: AnyObject, kind: PlatformViewDefinition.ViewKind) { preconditionFailure("") } + // open class func makeDrawingView(options: PlatformDrawableOptions) -> any PlatformDrawable { preconditionFailure("") } + open class func setPath(_ path: Path, shapeView: AnyObject) { preconditionFailure("") } + open class func setProjectionTransform(_ transform: ProjectionTransform, projectionView: AnyObject) { preconditionFailure("") } + open class func getRBLayer(drawingView: AnyObject) -> AnyObject? { preconditionFailure("") } + open class func setIgnoresEvents(_ state: Bool, of view: AnyObject) { preconditionFailure("") } + open class func setAllowsWindowActivationEvents(_ value: Bool?, for view: AnyObject) { preconditionFailure("") } + open class func setHitTestsAsOpaque(_ value: Bool, for view: AnyObject) { preconditionFailure("") } } extension DisplayList.ViewUpdater { @@ -86,7 +86,7 @@ extension DisplayList.GraphicsRenderer { layer.bounds = CGRect(origin: .zero, size: size) layer.layoutIfNeeded() } - fatalError("Blocked by GraphicsContext") + preconditionFailure("Blocked by GraphicsContext") // ctx.drawLayer } #endif diff --git a/Sources/OpenSwiftUICore/Shape/Path/FixedRoundedRect.swift b/Sources/OpenSwiftUICore/Shape/Path/FixedRoundedRect.swift index b92df697..a8bf0077 100644 --- a/Sources/OpenSwiftUICore/Shape/Path/FixedRoundedRect.swift +++ b/Sources/OpenSwiftUICore/Shape/Path/FixedRoundedRect.swift @@ -26,6 +26,6 @@ struct FixedRoundedRect: Equatable { } func distance(to point: CGPoint) -> CGFloat { - fatalError("TODO") + preconditionFailure("TODO") } } diff --git a/Sources/OpenSwiftUICore/Shape/Path/Path.swift b/Sources/OpenSwiftUICore/Shape/Path/Path.swift index ce629516..44ae9511 100644 --- a/Sources/OpenSwiftUICore/Shape/Path/Path.swift +++ b/Sources/OpenSwiftUICore/Shape/Path/Path.swift @@ -147,7 +147,7 @@ public struct Path/*: Equatable, LosslessStringConvertible*/ { /// @available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *) public init(roundedRect rect: CGRect, cornerRadii: RectangleCornerRadii, style: RoundedCornerStyle = .continuous) { - fatalError("TODO") + preconditionFailure("TODO") } #endif @@ -216,19 +216,19 @@ public struct Path/*: Equatable, LosslessStringConvertible*/ { /// A description of the path that may be used to recreate the path /// via `init?(_:)`. public var description: String { - fatalError("TODO") + preconditionFailure("TODO") } #if canImport(CoreGraphics) /// An immutable path representing the elements in the path. public var cgPath: CGPath { - fatalError("TODO") + preconditionFailure("TODO") } #endif /// A Boolean value indicating whether the path contains zero elements. public var isEmpty: Bool { - fatalError("TODO") + preconditionFailure("TODO") } /// A rectangle containing all path segments. @@ -237,7 +237,7 @@ public struct Path/*: Equatable, LosslessStringConvertible*/ { /// in the path but not including control points for Bézier /// curves. public var boundingRect: CGRect { - fatalError("TODO") + preconditionFailure("TODO") } /// Returns true if the path contains a specified point. @@ -245,18 +245,18 @@ public struct Path/*: Equatable, LosslessStringConvertible*/ { /// If `eoFill` is true, this method uses the even-odd rule to define which /// points are inside the path. Otherwise, it uses the non-zero rule. public func contains(_ p: CGPoint, eoFill: Bool = false) -> Bool { - fatalError("TODO") + preconditionFailure("TODO") } /// Calls `body` with each element in the path. public func forEach(_ body: (Path.Element) -> Void) { - fatalError("TODO") + preconditionFailure("TODO") } /// Returns a stroked copy of the path using `style` to define how the /// stroked outline is created. public func strokedPath(_ style: StrokeStyle) -> Path { - fatalError("TODO") + preconditionFailure("TODO") } /// Returns a partial copy of the path. @@ -265,7 +265,7 @@ public struct Path/*: Equatable, LosslessStringConvertible*/ { /// which must be fractions between zero and one defining points /// linearly-interpolated along the path. public func trimmedPath(from: CGFloat, to: CGFloat) -> Path { - fatalError("TODO") + preconditionFailure("TODO") } } @@ -290,11 +290,11 @@ extension Path { } init(_ path: CGPath) { - fatalError("TODO") + preconditionFailure("TODO") } init(_ mutablePath: CGMutablePath) { - fatalError("TODO") + preconditionFailure("TODO") } // FIXME diff --git a/Sources/OpenSwiftUICore/Shape/Rectangle.swift b/Sources/OpenSwiftUICore/Shape/Rectangle.swift index c00f066b..df410d94 100644 --- a/Sources/OpenSwiftUICore/Shape/Rectangle.swift +++ b/Sources/OpenSwiftUICore/Shape/Rectangle.swift @@ -4,7 +4,7 @@ public import Foundation @frozen public struct Rectangle: Shape { public func path(in rect: CGRect) -> Path { - fatalError("TODO") + preconditionFailure("TODO") } /// Creates a new rectangle shape. diff --git a/Sources/OpenSwiftUICore/Shape/RoundedRectangle.swift b/Sources/OpenSwiftUICore/Shape/RoundedRectangle.swift index b2cc786b..9b4b1556 100644 --- a/Sources/OpenSwiftUICore/Shape/RoundedRectangle.swift +++ b/Sources/OpenSwiftUICore/Shape/RoundedRectangle.swift @@ -18,7 +18,7 @@ public struct RoundedRectangle: Shape { } public func path(in rect: CGRect) -> Path { - fatalError("TODO") + preconditionFailure("TODO") } public var animatableData: CGSize.AnimatableData { get { cornerSize.animatableData } diff --git a/Sources/OpenSwiftUICore/Shape/ShapeStyle/BlendMode.swift b/Sources/OpenSwiftUICore/Shape/ShapeStyle/BlendMode.swift index 4d8799b5..9bf921c9 100644 --- a/Sources/OpenSwiftUICore/Shape/ShapeStyle/BlendMode.swift +++ b/Sources/OpenSwiftUICore/Shape/ShapeStyle/BlendMode.swift @@ -116,7 +116,7 @@ public struct _BlendModeShapeStyle