Is it possible to create an iOS Widget Extension in EAS Build’s Managed Workflow?
I know that EAS Build does not yet support Widget Extension. However, I think it is technically possible because we can update the contents of the ios/ folder with the Config Plugin during Prebuild.
However, adding the Widget Extension on XCode also updates the project.pbxproj file, so we need to reflect the differences as well, but it is tough to update the pbxproj file automatically in Config Plugin. Is there a good way to achieve this?
If it is difficult to do so, I would like to eject.
you can check GitHub - OneSignal/onesignal-expo-plugin: The OneSignal Expo plugin allows you to use OneSignal without leaving the managed workflow. Developed in collaboration with SweetGreen.
they are adding notifications service extensions in that plugin
support for generating credentials was added recently (no docs yet other than PR description [eas-cli] generate credentilas for iOS app extensions by wkozyra95 · Pull Request #1039 · expo/eas-cli · GitHub) (or you could use credentilas.json)
expo does not support entitlements for multiple targets, so your extension would get the same one as the main target
Thanks for your information!
I am surprised that such an implementation example already exists. I will try to implement it with reference to this one.
Please let us know how it goes, I’m also needing to write a widget for iOS and Android soon.
I have successfully created widgets in Managed Workflow and released them on production! @wkozyra Thanks for your advice
The development process was to create a Widget in Android and iOS as usual in the prebuilt (ejected) state and then create Config Plugins to make the same file structure. The process may be similar to provisioning with Ansible, etc.
For Android, it was relatively easy because all I had to do was prepare files. However, for iOS, it wasn’t easy because the “pbxproj” file needed to be updated (onesignal-expo-plugin was very helpful). The more files (swift files, fonts, localization files, etc.) used for widgets, the more difficult it becomes. It is hard but not impossible if the contents of the pbxproj file are steadily modified to be the same.
I created a minimal example repository for your reference.
It contains only minimum features. It will be more complicated when you create it. You might need Shared Groups, the ability to reflect app updates, etc. But who wants to create widget might refer.
Thank you very much for this example I will take a look at this I have to do this as well!
The wish for widget support is huge out there - Widget support | Voters | Expo
Thanks a lot for this. Do you know if there are any guides to how to add Shared Groups?
The followings might be helpful.
Thanks @gaishimo-omoidasu I have managed to set this up by prebuilding and then defining the groups in Xcode. But is there some way I could set up groups programatically or in the config file? I can’t really find any good documentation on how to do this programatically.
I have not tried this myself, but the approach I would use is:
- Create a new app.
npx expo prebuild -p ios
- Commit the “
ios” directory to Git
- Make your changes in Xcode
git diff to check what changes were made to the project files
- Figure out how to make those same changes in a config plugin
Ok, so I’ve gotten a step further but have a “small” issue.
I’ve used the eas-widget-example @gaishimo-omoidasu shared and added a widgets.entitlements file in widget/ios/widget.
withWidgetXCode.ts I added
"widget.entitlements" to the
and to the build phase
to the build configurations part in the bottom.
Now, this seems to make Xcode happy and if I run prebuild locally then EAS Build, it works like a charm.
✔ Synced capabilities: Enabled: Push Notifications, App Groups
✔ Synced capability identifiers: Linked: group.mynamespace
But, if I don’t prebuild locally and run eas, it get:
✔ Synced capabilities: Disabled: Push Notifications, App Groups
✔ Synced capability identifiers: No updates
I know oneSignal adds groups in a different way, but I tried it and that seems to only add a group to the root project and not the widget.
So, I’m hoping you can help me with these two questions.
- Does what I have done make sense or does it seem wrong or insufficient?
- Why does it work if I prebuild locally, but not without?
have you configured the app extension as per this guide? iOS App Extensions - Expo Documentation