When working on my macOS application, which has some TelemetryDeck analytics events being sent on the TCA reducer layer, I received this error while trying to edit a SwiftUI view and tried to see the previews. Unfortunately, previews seem not to work due to TelemetryManage.initialize(...) not being called.
Given how common SwiftUI is and will become in the future, I think there should be a built-in solution that prevents this from happening. My SwiftUI previews are already all in an if DEBUG, so if this error didn't happen on debug builds for example, this would help. Or even better, maybe there's a way to detect when run in a preview, this could be auto-detected and some mocked version could be initialized.
Here's what I see:
Note that my app is modularized using this approach, therefore I don't need to build the top-level App to see the preview of a component (this is by design for improved build performance). This might be why it's not happening in all projects.
When working on my macOS application, which has some TelemetryDeck analytics events being sent on the TCA reducer layer, I received this error while trying to edit a SwiftUI view and tried to see the previews. Unfortunately, previews seem not to work due to
TelemetryManage.initialize(...)
not being called.Given how common SwiftUI is and will become in the future, I think there should be a built-in solution that prevents this from happening. My SwiftUI previews are already all in an
if DEBUG
, so if this error didn't happen on debug builds for example, this would help. Or even better, maybe there's a way to detect when run in a preview, this could be auto-detected and some mocked version could be initialized.Here's what I see:![Screen Shot 2022-08-29 at 19 49 18](https://user-images.githubusercontent.com/6942160/187266526-84da0f58-b07e-40ad-905d-756e3df9f0e7.png)
Note that my app is modularized using this approach, therefore I don't need to build the top-level
App
to see the preview of a component (this is by design for improved build performance). This might be why it's not happening in all projects.