Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Widget Extension UnitTest Error: "Undefined Symbol: nominal type descriptor for [...]."

I have a Widget Extension for my app with a struct MyStruct defined in my extension, with target membership MyAppWidgetExtension. I also have a UnitTesting target, in which I want to have UnitTests for my main App as well as for the WidgetExtension.

As soon as I add a file to the UnitTesting-target, which has a var/let of type MyStruct, e.g. var foo: MyStruct? (which is recognized by the compiler by @testable import MyAppWidgetExtension within this file), executing the UnitTests yields a compiler error: "Undefines symbol: nominal type descriptor for MyAppWidgetExtension.MyStruct".

Any idea what's going wrong here?

like image 343
Alienbash Avatar asked Oct 23 '25 14:10

Alienbash


1 Answers

I've found a solution, which feels like a workaround, but does the job:

  • Define MyStruct as well in the main app target with target membership MyApp
  • In the UnitTest use @testable import MyApp in order to be able to use MyStruct from the app target

Now the compiler does not complain anymore.

like image 165
Alienbash Avatar answered Oct 26 '25 07:10

Alienbash



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!