0

I added a WidgetExtension via Xcode to my react-native project, however I can't get them to work simultaneously. This is because both main.m and my widget are 'main'. Xcode says error: 1 duplicate symbol for architecture arm64

To fix this I removed main.m from Compile Sources in Xcode, so now my widget works fine, but react no longer does. Same for the other way around (removing @main from the widget), then react works fine, but the widget no longer does.

How can I get these two to work simultaneously?

Kipnoedels
  • 1,118
  • 7
  • 22
  • Are you including the Objective-C file in your widget target? Widgets are self-contained and done exclusively in SwiftUI. The rest of your project doesn't matter. – Claus Jørgensen Oct 03 '20 at 13:38
  • @ClausJørgensen The main.m file belongs to react-native (auto generated). I wrote the app in react native and only the widget is made in swift(ui), but because the widget requires the `@main` attribute, e.g. `@main struct MyCustomWidget: Widget {...}` it interferes with the react-native project. – Kipnoedels Oct 03 '20 at 13:47
  • @Kipnodels it can only interfere if your project is setup incorrectly. It sounds like whatever you use to generate the react project is failing to handle the widget extension. Try look at your project structure yourself in Xcode, see which files are included in which targets. – Claus Jørgensen Oct 03 '20 at 20:18

1 Answers1

0

I fixed this by modifying the widget files in the Compile Sources.

Kipnoedels
  • 1,118
  • 7
  • 22