I found the answer here - https://stackoverflow.com/a/32893825:
> To use the #if DEBUG macro then you have to define the "Swift Compiler - Custom Flags -Other Flags" to contain the value
D DEBUG
Post
Replies
Boosts
Views
Activity
In the Transaction Manager in Xcode, try refunding a transaction on a non-consumable product I did try that, but my paymentQueue(_:didRevokeEntitlementsForProductIdentifiers:) method was not called. Likewise if the transaction is deleted.
It does work, but only if you haven't run the app previously, such that the system "remembers" a non-default size that was used then, or if you manage to reset that memory.
There may be a simpler way to do that, but so far the only reliable way I've found is to:
delete the reference to my app in ~/Library/Application\ Support/com.apple.windowmanager/state.plist and resave it
delete my app's folder in ~/Library/Containers/ (that's for a sandboxed app, it may otherwise be under Preferences)
empty the trash
restart the Mac
Also, so far I've only tested this with the Window scene rather than WindowGroup. But it was apparently not working with Window either till I managed to clear the previous non-default size using the steps above.
The problem was not present in MacOS Ventura 13.6.7 and Xcode 15.2, as seen in this screenshot, using the same code, in which all the sliders have the correct appearance:
Testing on a clean installation of MacOS 14.4, with XCode 15.4, it's broken there in the same way as in MacOS 14.5, and in the beta of MacOS 15 as well.
Yes, I hadn't noticed it before, but I'm seeing that error message too. That's probably a good clue as to what's broken under the hood. Do you also see the button (or "thumb") growing in size as the angle approaches 90°? That suggests that the rotationEffect is using the wrong matrix for any non-zero rotation, even though it only becomes singular at 90° (or multiple thereof). Oddly, other Shapes, like the Rectangles in my example, and even the center line of the Sliders, are rotated correctly, it's only the Slider's thumb that explodes.
@reindebock Yes, that's a good workaround for vertical sliders. Instead of including the whole SwiftUIIntrospect library, one can also just wrap the NSSlider in a NSViewRepresentable, (as that library presumably does under the hood, along the lines shown for iOS at https://swdevnotes.com/swift/2021/how-to-customise-the-slider-in-swiftui/#documentTop#use-uislider-from-uikit )
Here's a version of that for MacOS:
import SwiftUI
struct VerticalSlider: NSViewRepresentable {
@Binding var value: Double
var bounds: ClosedRange<Double>
class Coordinator: NSObject {
var value: Binding<Double>
var bounds: ClosedRange<Double>
init(value: Binding<Double>, bounds: ClosedRange<Double> = 0...1) {
self.value = value
self.bounds = bounds
}
@objc func valueChanged(_ sender: NSSlider) {
self.value.wrappedValue = sender.doubleValue
}
}
func makeCoordinator() -> VerticalSlider.Coordinator {
Coordinator(value: $value)
}
func makeNSView(context: Context) -> NSSlider {
let slider = NSSlider(frame: .zero)
slider.isVertical = true
slider.minValue = bounds.lowerBound
slider.maxValue = bounds.upperBound
slider.doubleValue = value
slider.action = #selector(Coordinator.valueChanged(_:))
slider.target = context.coordinator
return slider
}
func updateNSView(_ nsView: NSSlider, context: Context) {
nsView.doubleValue = value
}
}
struct SliderTestView: View {
@State var speed = 5.0
var body: some View {
VStack() {
Text("\(speed)")
VerticalSlider(value: $speed, bounds: 1.0...10.0)
.onChange(of: speed) { speed in
print("\(speed)")
}
.frame(width: 50, height: 200)
}
}
}
#Preview {
SliderTestView()
}