Skip to content

Commit

Permalink
Work around macro bug un XCode 16 betas
Browse files Browse the repository at this point in the history
  • Loading branch information
r-dent committed Aug 22, 2024
1 parent b8c3029 commit 5b9b121
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions Sources/StreamDeckSimulator/Views/SimulatorDialTouchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,21 @@
import SwiftUI
import StreamDeckKit

@StreamDeckView
struct SimulatorDialTouchView {
// The explicit implementation of the `StreamDeckView` protocol is a workaround. Normally we would use the `@StreamDeckView`
// macro here. But due to a bug in XCode 16 and 16.1 betas, the `if #available` check that the macro implemented,
// always threw an error.
// TODO: If you read this and XCode 16 was finally released, please check if just using the macro is working again.

Check failure on line 34 in Sources/StreamDeckSimulator/Views/SimulatorDialTouchView.swift

View workflow job for this annotation

GitHub Actions / Run SwiftLint

Todo Violation: TODOs should be resolved (If you read this and XCode 16 ...) (todo)

struct SimulatorDialTouchView: StreamDeckView {

@Environment(\.streamDeckViewContext) private var context
private var viewSize: CGSize { context.size }
private var viewIndex: Int { context.index }

let client: StreamDeckSimulatorClient?

@MainActor
@ViewBuilder
var streamDeckBody: some View {
StreamDeckDialView {
Color.clear
Expand All @@ -59,4 +69,19 @@ struct SimulatorDialTouchView {
}
)
}

@MainActor
var body: some View {
if #available (iOS 17, *) {
return streamDeckBody
.onChange(of: StreamDeckKit._nextID) {
context.updateRequired()
}
} else {
return streamDeckBody
.onChange(of: StreamDeckKit._nextID) { _ in
context.updateRequired()
}
}
}
}

0 comments on commit 5b9b121

Please sign in to comment.