How to create live activity object in tests? It returns error ActivityKit.ActivityAuthorizationError.unsupportedTarget

31 Views Asked by At

When I'm trying to mock a Live Activity object in unit tests, it always returns error ActivityKit.ActivityAuthorizationError.unsupportedTarget but the ActivityKit is Swift native framework. The main app is working as expected, live activities are displayed without issues.

Here is example when I let it crash on purpose during test setup phase. The error message is: Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: ActivityKit.ActivityAuthorizationError.unsupportedTarget

enter image description here

When I tried making ActivityKit testable, the error message is: Module 'ActivityKit' was not compiled for testing

enter image description here

Any idea how to fix it?

0

There are 0 best solutions below