Closed chbeer closed 2 years ago
Hi @chbeer,
As UIFeedbackGenerator alongside with its subclasses are unavailable on macOS the usage of WhatsNew.HapticFeedback
should be surrounded with an OS-Availability check.
A fix for your PR https://github.com/SvenTiigi/WhatsNewKit/pull/60 could be the following one.
// ...
decoder.userInfo["continue"] = WhatsNew.PrimaryAction(
title: "Continue",
backgroundColor: .accentColor,
foregroundColor: .white,
hapticFeedback: {
#if !os(macOS)
return .notification(.success)
#else
return nil
#endif
}(),
onDismiss: {
print("WhatsNewView has been dismissed")
}
)
// ...
#if !os(macOS)
XCTAssertEqual(whatsNew.primaryAction.hapticFeedback, .notification(.success))
#endif
Fixed my PR with your suggestion
Notifications and haptics are not available on macOS. So code that uses them does not build on macOS. You can add conditions to fix this but it makes things more complicated.
Would creating dummies for these on macOS be a way to go? Then the same code would build also on macOS.
There could be a log message on macOS.