I am trying to create a custom module in my React Native App and I am using Expo to do so. When i follow the expo instructions I end up developing my native module in xcode at the path "Pods/Development Pods/MyModule". I have things working in the sense that I can call functions defined in my custom module from the typescript project and see proper results in the simulator, but I am struggling to figure out how to properly create a widget extension in this environment.
When I create a new target and select the widget extension option, the folder for the widget extension gets created in the top level project, not my custom module which exists in the Pods folder where I am developing the custom module.
So, I tried moving the extension folder for MyWidget into the MyModule folder. When I attempted to then run the project, I received an error mentioning duplicate symbol and it mentioned "_main" so I removed the @main from MyWidget/MyWidgetBundle but when I run the project I hit a new error saying that the app cannot locate MyApp.app/Plugins/MyWidgetExtension.appex. This error seems related to the part where i moved the widget folder into Pods/MyModule, but I don't understand how I can skip that step If I am trying to add a widget to MyModule and that is the location that expo instructs development.
Thanks In advance for any help!
instructions I was following: /modules/get-started/
I am trying to create a custom module in my React Native App and I am using Expo to do so. When i follow the expo instructions I end up developing my native module in xcode at the path "Pods/Development Pods/MyModule". I have things working in the sense that I can call functions defined in my custom module from the typescript project and see proper results in the simulator, but I am struggling to figure out how to properly create a widget extension in this environment.
When I create a new target and select the widget extension option, the folder for the widget extension gets created in the top level project, not my custom module which exists in the Pods folder where I am developing the custom module.
So, I tried moving the extension folder for MyWidget into the MyModule folder. When I attempted to then run the project, I received an error mentioning duplicate symbol and it mentioned "_main" so I removed the @main from MyWidget/MyWidgetBundle but when I run the project I hit a new error saying that the app cannot locate MyApp.app/Plugins/MyWidgetExtension.appex. This error seems related to the part where i moved the widget folder into Pods/MyModule, but I don't understand how I can skip that step If I am trying to add a widget to MyModule and that is the location that expo instructs development.
Thanks In advance for any help!
instructions I was following: https://docs.expo.dev/modules/get-started/
Share edited Mar 10 at 10:56 David Pasztor 54.9k9 gold badges97 silver badges127 bronze badges asked Mar 9 at 20:43 theredfoxtheredfox 92 bronze badges 1- I also tried creating the widget directly in the Module directory but the live activity I am trying to create is black. It definitely shows up, but it doesnt seem like the widget is actual found when I create things this way. I added a log the to render of the widget and it does not show in the console. – theredfox Commented Mar 9 at 21:14
1 Answer
Reset to default 0You cannot directly create a widget using pods. Pods, as entities from CocoaPods, are libraries, while widgets are executables that can include libraries but cannot be included themselves; therefore, a widget cannot be a pod. However, you can write almost all of the widget's code within a pod and link it to the created widget target in the top-level project.
Additionally, you will notice that your main app target is also located in your top-level project. A widget should be positioned nearby. It will be packaged with your main app when you upload your app to the App Store. When running locally, you can see your widget's target in the target selector of Xcode.
Regarding the "_main" error, all binaries contain symbols that mark different parts of the executable. One of these symbols is "main," which indicates the starting point for program execution by the operating system. In your case, you had an app that includes a library. Your app has a main function, which becomes the _main symbol in the resulting application. Your widget is another executable with its own main function. You placed your widget's code in the library, which was linked to your main app. Consequently, your resulting app contains the main function from the main app as well as the main function from the widget.