I've encountered an issue where storing a throws(PermissionError) closure as a property inside a SwiftUI View causes a runtime crash on iOS 17, while it works correctly on iOS 18.
Here’s an example of the affected code:
enum PermissionError: Error {
case denied
}
struct PermissionCheckedView<AllowedContent: View, DeniedContent: View>: View {
var protectedView: () throws(PermissionError) -> AllowedContent
var deniedView: (PermissionError) -> DeniedContent
init(
@ViewBuilder protectedView: @escaping () throws(PermissionError) -> AllowedContent,
@ViewBuilder deniedView: @escaping (PermissionError) -> DeniedContent
) {
self.protectedView = protectedView
self.deniedView = deniedView
}
public var body: some View {
switch Result(catching: protectedView) {
case .success(let content): content
case .failure(let error): deniedView(error)
}
}
}
@main
struct TestApp: App {
var body: some Scene {
WindowGroup {
PermissionCheckedView {
} deniedView: { _ in
}
}
}
}
Specifically this is the stack trace (sorry for the picture I didn't know how to get the txt):
If I use var protectedView: () throws -> AllowedContent without typed throws it works.
Post
Replies
Boosts
Views
Activity
I need to read results of a test in Xcode post-action of Test.
So the script that runs after tests contains
SUMMARY=$(xcrun xcresulttool get test-results summary --path $RESULT_FILE 2>> "$LOGS")
If I run my script from terminal, everything is ok but if I launch tests and the post-action is executed, I got
Warning: unknown environment variable SWIFT_DEBUG_INFORMATION_FORMAT
Warning: unknown environment variable SWIFT_DEBUG_INFORMATION_VERSION
Warning: unknown environment variable SWIFT_DEBUG_INFORMATION_FORMAT
Warning: unknown environment variable SWIFT_DEBUG_INFORMATION_VERSION
Error: Failed to create a new result bundle reader, underlying error: failed to read metadata with underlying error (type: FileSystemError: 3 - [:] - The operation couldn’t be completed. (MinimalTSCBasic.FileSystemError error 3.)
Usage: xcresulttool <subcommand>
See 'xcresulttool --help' for more information.
It might be that the environment set by Xcode is missing something but I cannot figure out what, any idea?