Closed jaanussiim closed 3 months ago
Hi @jaanussiim, I'm sorry you are running into issues, but also I'm not really sure there is much we can do about this. No matter what there are always going to be limitations of what Swift can handle. An enum with 105 cases is quite extreme, and if Swift is having problems with it I'm not sure there is much we can do. We do have some plans in the future that will help eliminate some stack frames from highly composed features, but even then you will still be able to run into the problem if you add even more cases to your enum.
I'd highly recommend simplifying this domain. Are all 105 features truly distinct from each other, or could some perhaps be combined and hold onto configuration state that controls their behavior? And if all 105 features are truly distinct, then you may need to just not use our stack navigation tools. You may be better off just using a vanilla NavigationStack
with NavigationPath
.
Another idea that comes to mind is to mark the State
and Action
enums as indirect
so that they are heap allocated instead of stack allocated. In order to test that you would need to copy and paste the code generated by @Reducer
and then prefix the enums with indirect
. If that works then we could consider building support for that into @Reducer
, but also this should be considered a bit of a hack. The real problem is that your domain is just not modeled in a way that scales.
I am going to convert this to a discussion because there really isn't much we can do in the near term about this.
Description
This is related to following discussion https://github.com/pointfreeco/swift-composable-architecture/discussions/3162
Currently in my project, have to run in release mode on local device while developing.
Sample code to reproduce the issue
Checklist
main
branch of this package.Expected behavior
No response
Actual behavior
No response
Steps to reproduce
No response
The Composable Architecture version information
1.11.2
Destination operating system
17.5.1
Xcode version information
15.4
Swift Compiler version information
No response