@ViewAction
macro does not work if store
property is in #if
block
#3629
Labels
bug
Something isn't working due to a bug in the library.
Description
When creating a multiplatform SwiftUI project in Xcode with different deployment targets for macOS and iOS, there is an issue with the
@Perception.Bindable
macro applied toStoreOf<MyReducer>
inside a view.Problem
On macOS 12.0,
@Perception.Bindable
is required.On iOS 17.0,
@Perception.Bindable
is hard-deprecated and requires@Bindable
instead.This leads to a conflicting requirement that prevents a single universal codebase. One possible workaround is using
#if canImport(AppKit)
:However, this introduces a secondary issue.
Secondary Issue
When using
@ViewAction(for:)
, it fails to process this conditional property declaration and throws the following error:@ViewAction requires 'MyView' to have a 'store' property of type 'Store'
This suggests that
@ViewAction(for:)
does not properly recognize the conditionally defined store property.Expected Behavior
Composable Architecture should provide a way to:
@Perception.Bindable
(for older macOS targets) and@Bindable
(for newer iOS versions).@ViewAction(for:)
can work correctly in a multiplatform environment.Composable Architecture Version: 1.18
Xcode Version: 16.2
Any guidance on how to handle this case in a clean and maintainable way would be appreciated.
Checklist
main
branch of this package.The text was updated successfully, but these errors were encountered: