Skip to content

Commit d665494

Browse files
committed
Update precondition implementation
1 parent 5954bc7 commit d665494

File tree

91 files changed

+316
-308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+316
-308
lines changed

Package.swift

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,21 @@ func envEnable(_ key: String, default defaultValue: Bool = false) -> Bool {
1717
}
1818
}
1919

20-
let isXcodeEnv = Context.environment["__CFBundleIdentifier"] == "com.apple.dt.Xcode"
21-
let development = envEnable("OPENSWIFTUI_DEVELOPMENT", default: false)
22-
23-
// Xcode use clang as linker which supports "-iframework" while SwiftPM use swiftc as linker which supports "-Fsystem"
24-
let systemFrameworkSearchFlag = isXcodeEnv ? "-iframework" : "-Fsystem"
20+
var sharedSwiftSettings: [SwiftSetting] = [
21+
.enableUpcomingFeature("BareSlashRegexLiterals"),
22+
.enableUpcomingFeature("InternalImportsByDefault"),
23+
.define("OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS"),
24+
.swiftLanguageMode(.v5),
25+
]
2526

2627
let releaseVersion = Context.environment["OPENSWIFTUI_TARGET_RELEASE"].flatMap { Int($0) } ?? 2024
28+
sharedSwiftSettings.append(.define("OPENSWIFTUI_RELEASE_\(releaseVersion)"))
29+
if releaseVersion >= 2021 {
30+
for year in 2021 ... releaseVersion {
31+
sharedSwiftSettings.append(.define("OPENSWIFTUI_SUPPORT_\(year)_API"))
32+
}
33+
}
34+
2735
let platforms: [SupportedPlatform] = switch releaseVersion {
2836
case 2024: // iOS 18.0
2937
[
@@ -53,18 +61,15 @@ default:
5361
]
5462
}
5563

56-
var sharedSwiftSettings: [SwiftSetting] = [
57-
.enableUpcomingFeature("BareSlashRegexLiterals"),
58-
.enableUpcomingFeature("InternalImportsByDefault"),
59-
.define("OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS"),
60-
.define("OPENSWIFTUI_RELEASE_\(releaseVersion)"),
61-
.swiftLanguageMode(.v5),
62-
]
64+
let isXcodeEnv = Context.environment["__CFBundleIdentifier"] == "com.apple.dt.Xcode"
6365

64-
if releaseVersion >= 2021 {
65-
for year in 2021 ... releaseVersion {
66-
sharedSwiftSettings.append(.define("OPENSWIFTUI_SUPPORT_\(year)_API"))
67-
}
66+
// Xcode use clang as linker which supports "-iframework" while SwiftPM use swiftc as linker which supports "-Fsystem"
67+
let systemFrameworkSearchFlag = isXcodeEnv ? "-iframework" : "-Fsystem"
68+
69+
let development = envEnable("OPENSWIFTUI_DEVELOPMENT")
70+
71+
if development {
72+
sharedSwiftSettings.append(.define("OPENSWIFTUI_DEVELOPMENT"))
6873
}
6974

7075
let warningsAsErrorsCondition = envEnable("OPENSWIFTUI_WERROR", default: isXcodeEnv && development)

Sources/OpenSwiftUI/Accessibility/Modifier/internal/AccessibilityConfigurationModifier.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ protocol AccessibilityConfigurationModifier {
1515
}
1616

1717
extension AccessibilityConfigurationModifier where Configuration == Never {
18-
var configuration: Configuration { fatalError() }
18+
var configuration: Configuration { preconditionFailure() }
1919
}

Sources/OpenSwiftUI/App/FinishLaunchTestAction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct FinishLaunchTestAction {
1717
#if os(iOS)
1818
UIApplication.shared.finishedTest(UIApplication.shared._launchTestName())
1919
#else
20-
fatalError("Unimplemented for other platform")
20+
preconditionFailure("Unimplemented for other platform")
2121
#endif
2222
}
2323
}

Sources/OpenSwiftUI/App/LegacyApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extension __App {
1919
var rootView: V
2020

2121
init() {
22-
fatalError("Not a standalone App.")
22+
preconditionFailure("Not a standalone App.")
2323
}
2424

2525
init(rootView: V) {

Sources/OpenSwiftUI/App/OpenSwiftUIApplication.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private final class OpenSwiftUIApplication: NSApplication {
2525
}
2626

2727
required init?(coder: NSCoder) {
28-
fatalError("init(coder:) has not been implemented")
28+
preconditionFailure("init(coder:) has not been implemented")
2929
}
3030
}
3131
#else

Sources/OpenSwiftUI/Core/Modifier/SceneModifier/TODO/_SceneModifier.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ extension _SceneModifier {
2222
extension _SceneModifier where Body == Never {
2323
@inline(__always)
2424
public func body(content _: SceneContent) -> Body {
25-
fatalError("body() should not be called on \(Self.self)")
25+
preconditionFailure("body() should not be called on \(Self.self)")
2626
}
2727
}

Sources/OpenSwiftUI/Core/Render/DisplayLink.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ final class DisplayLink: NSObject {
2828

2929
#if os(iOS)
3030
init(host: AnyUIHostingView, window: UIWindow) {
31-
fatalError("TODO")
31+
preconditionFailure("TODO")
3232
}
3333
#elseif os(macOS)
3434
init(host: AnyUIHostingView, window: NSWindow) {
35-
fatalError("TODO")
35+
preconditionFailure("TODO")
3636
}
3737
#endif
3838

Sources/OpenSwiftUI/EventHandling/Focus/FocusStoreLocation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ class FocusStoreLocation<A: Hashable>: AnyLocation<A>, @unchecked Sendable {
1111
}
1212

1313
override func get() -> A {
14-
fatalError("TODO")
14+
preconditionFailure("TODO")
1515
}
1616

1717
override func set(_ value: A, transaction: Transaction) {
18-
fatalError("TODO")
18+
preconditionFailure("TODO")
1919
}
2020

2121
typealias Value = A
2222

23-
override init() { fatalError() }
23+
override init() { preconditionFailure() }
2424

2525
var store: FocusStore
2626
weak var host: GraphHost?

Sources/OpenSwiftUI/Integration/Representable/UIKit/UIViewRepresentable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ extension UIViewRepresentable {
185185
static func _modifyBridgedViewInputs(_ inputs: inout _ViewInputs) {}
186186

187187
public static func _makeView(view: _GraphValue<Self>, inputs: _ViewInputs) -> _ViewOutputs {
188-
fatalError("TODO")
188+
preconditionFailure("TODO")
189189
}
190190

191191
public static func _makeViewList(view: _GraphValue<Self>, inputs: _ViewListInputs) -> _ViewListOutputs {
192-
fatalError("TODO")
192+
preconditionFailure("TODO")
193193
}
194194
}
195195

Sources/OpenSwiftUI/Integration/UIKit/UIHostingController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ open class UIHostingController<Content> : UIViewController where Content : View
2828
}
2929

3030
public required init?(coder: NSCoder) {
31-
fatalError("init(coder:) must be implemented in a subclass and call super.init(coder:, rootView:)")
31+
preconditionFailure("init(coder:) must be implemented in a subclass and call super.init(coder:, rootView:)")
3232
}
3333

3434
func _commonInit() {

0 commit comments

Comments
 (0)