Closed mrtnlst closed 1 year ago
Hi @mrtnlst, have you confirmed that this is actually a problem with TCA, or just a problem in general Swift projects when importing release libraries into debug projects? I'm not aware of anything we can do specifically in the library to prevent this kind of crash. I would imagine this happens in any Swift project.
And beyond that, we highly recommend against doing this in general. Building TCA for release causes all types of warnings, preconditions and helpers to be omitted from the library. You will no longer be notified when the library detects improper usage of an API, the _printChanges
operator will not work, and worst of all TestStore
will not work at all so you can't even write tests.
Since we're not really sure this is an actual TCA problem I am going to convert this to a discussion as we all try to figure out what is going on.
Description
I'm facing an obscure crash when building a static library that uses TCA (only links, not embeds) in a release configuration to customers. When the framework is added to an app target (alongside adding TCA) and building it in a debug configuration, a crash occurs in WithViewStore's initializer. If we remove all code inside the
#if DEBUG
compiler directive there, it works.If this is an issue of TCA or something entirely else we don't know. We have faced this issue since at least version 0.35.1.
Checklist
main
branch of this package.Expected behavior
I expect that a release built binary framework (that uses TCA as a dependency) can be build and run inside an app in either debug or release configuration.
Actual behavior
A release built binary framework (that uses TCA as a dependency) can only be run inside an app in release configuration.
Steps to reproduce
I have provided an example project at https://github.com/mrtnlst/SampleProject. It consists of:
View
andWithViewStore
that has TCA as a Target DependencyBy default the project embeds the framework using the + button under Frameworks, Libraries, and Embedded Content and you can see it builds and launches successfully (displaying a button).
To reproduce the crash:
SampleProjectFramework
in FinderSampleProjectFramework
inside the framework artefact to Frameworks, Libraries, and Embedded ContentHints
The issue doesn't occur when
#if DEBUG
compiler directiveThe Composable Architecture version information
1.0.0
Destination operating system
iOS 16
Xcode version information
Xcode 14.3
Swift Compiler version information