Skip to content

Commit 85edbea

Browse files
committed
Change indentation in RuntimeWarnings.swift to 4 spaces
1 parent 8b0fa66 commit 85edbea

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

DebugLayout/Sources/DebugLayout/RuntimeWarnings.swift

+42-42
Original file line numberDiff line numberDiff line change
@@ -5,54 +5,54 @@
55
// https://www.pointfree.co/blog/posts/70-unobtrusive-runtime-warnings-for-libraries
66

77
#if DEBUG
8-
import os
9-
import XCTestDynamicOverlay
8+
import os
9+
import XCTestDynamicOverlay
1010

11-
// NB: Xcode runtime warnings offer a much better experience than traditional assertions and
12-
// breakpoints, but Apple provides no means of creating custom runtime warnings ourselves.
13-
// To work around this, we hook into SwiftUI's runtime issue delivery mechanism, instead.
14-
//
15-
// Feedback filed: https://gist.github.com/stephencelis/a8d06383ed6ccde3e5ef5d1b3ad52bbc
16-
private let rw = (
17-
dso: { () -> UnsafeMutableRawPointer in
18-
let count = _dyld_image_count()
19-
for i in 0..<count {
20-
if let name = _dyld_get_image_name(i) {
21-
let swiftString = String(cString: name)
22-
if swiftString.hasSuffix("/SwiftUI") {
23-
if let header = _dyld_get_image_header(i) {
24-
return UnsafeMutableRawPointer(mutating: UnsafeRawPointer(header))
11+
// NB: Xcode runtime warnings offer a much better experience than traditional assertions and
12+
// breakpoints, but Apple provides no means of creating custom runtime warnings ourselves.
13+
// To work around this, we hook into SwiftUI's runtime issue delivery mechanism, instead.
14+
//
15+
// Feedback filed: https://gist.github.com/stephencelis/a8d06383ed6ccde3e5ef5d1b3ad52bbc
16+
private let rw = (
17+
dso: { () -> UnsafeMutableRawPointer in
18+
let count = _dyld_image_count()
19+
for i in 0..<count {
20+
if let name = _dyld_get_image_name(i) {
21+
let swiftString = String(cString: name)
22+
if swiftString.hasSuffix("/SwiftUI") {
23+
if let header = _dyld_get_image_header(i) {
24+
return UnsafeMutableRawPointer(mutating: UnsafeRawPointer(header))
25+
}
26+
}
27+
}
2528
}
26-
}
27-
}
28-
}
29-
return UnsafeMutableRawPointer(mutating: #dsohandle)
30-
}(),
31-
log: OSLog(subsystem: "com.apple.runtime-issues", category: "ComposableArchitecture")
32-
)
29+
return UnsafeMutableRawPointer(mutating: #dsohandle)
30+
}(),
31+
log: OSLog(subsystem: "com.apple.runtime-issues", category: "ComposableArchitecture")
32+
)
3333
#endif
3434

3535
@_transparent
3636
@inline(__always)
3737
func runtimeWarning(
38-
_ message: @autoclosure () -> StaticString,
39-
_ args: @autoclosure () -> [CVarArg] = [],
40-
file: StaticString? = nil,
41-
line: UInt? = nil
38+
_ message: @autoclosure () -> StaticString,
39+
_ args: @autoclosure () -> [CVarArg] = [],
40+
file: StaticString? = nil,
41+
line: UInt? = nil
4242
) {
43-
#if DEBUG
44-
let message = message()
45-
if _XCTIsTesting {
46-
if let file = file, let line = line {
47-
XCTFail(String(format: "\(message)", arguments: args()), file: file, line: line)
48-
} else {
49-
XCTFail(String(format: "\(message)", arguments: args()))
50-
}
51-
} else {
52-
unsafeBitCast(
53-
os_log as (OSLogType, UnsafeRawPointer, OSLog, StaticString, CVarArg...) -> Void,
54-
to: ((OSLogType, UnsafeRawPointer, OSLog, StaticString, [CVarArg]) -> Void).self
55-
)(.fault, rw.dso, rw.log, message, args())
56-
}
57-
#endif
43+
#if DEBUG
44+
let message = message()
45+
if _XCTIsTesting {
46+
if let file = file, let line = line {
47+
XCTFail(String(format: "\(message)", arguments: args()), file: file, line: line)
48+
} else {
49+
XCTFail(String(format: "\(message)", arguments: args()))
50+
}
51+
} else {
52+
unsafeBitCast(
53+
os_log as (OSLogType, UnsafeRawPointer, OSLog, StaticString, CVarArg...) -> Void,
54+
to: ((OSLogType, UnsafeRawPointer, OSLog, StaticString, [CVarArg]) -> Void).self
55+
)(.fault, rw.dso, rw.log, message, args())
56+
}
57+
#endif
5858
}

0 commit comments

Comments
 (0)