iOS Widget Extension on EAS Build

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

3 Likes

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.

1 Like

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 :+1:

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.

Thanks,

4 Likes

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

1 Like

Thanks a lot for this. Do you know if there are any guides to how to add Shared Groups?

The followings might be helpful.

https://developer.apple.com/documentation/xcode/configuring-app-groups

1 Like

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
  • Run 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.

In withWidgetXCode.ts I added "widget.entitlements" to the TOP_LEVEL_FILES
and to the build phase

xcodeProject.addBuildPhase(
      ["widget.swift", "widget.entitlements"],...

and

CODE_SIGN_ENTITLEMENTS: "widget/widget.entitlements",

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.

  1. Does what I have done make sense or does it seem wrong or insufficient?
  2. 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

1 Like

I’ve followed the eas-widget-example posted by @gaishimo-omoidasu but my app has two targets (one for the widget and one for the widget configuration intent) My plugin basically works but I am running into issues when adding multiple targets to my .pbxproj file. Does anyone have any thoughts or insight into this?

I think I’m having a similar issue. I got the widget up and running, but now I’m trying to add the oneSignal plugin for push notifications and the widget won’t build anymore. I’ve posted an issue here: [Bug]: Second extension fails to build – Could not find target · Issue #166 · OneSignal/onesignal-expo-plugin · GitHub

1 Like

Looks like there are solutions for this now:

iOS - GitHub - bndkt/react-native-widget-extension: Expo config plugin to add widgets and live activities to a React Native app
Android - GitHub - sAleksovski/react-native-android-widget: Build Android Widgets with React Native