Notes on the above article:
add /targets directory
add /targets/widgets directory
add /targets/widgets/expo-target.config.js file
something like:
/** @type {import('@bacons/apple-targets').Config} */ module.exports = { type: 'widget', name: 'My Widget', frameworks: ['SwiftUI'], colors: { $accent: 'steelblue', }, deploymentTarget: '13.4', };
add /targets/widgets/target.entitlements
for code signing to work, you need to teamId to app.config.js in plugins
{ "plugins": [ [ "@bacons/apple-targets", { "teamId": "XXXXXXXXXX" } ] ] }
with expo-apple-targets in place we can run npx expo prebuild and it should build the widget
careful of SwiftUI Preview being really buggy
setup up App Groups to share data between main app and the widget
{ "ios": { "entitlements": { "com.apple.security.application-groups": ["group.cogell.gym-time.data"] } } }
module.exports = { type: 'widget', ... entitlements: { 'com.apple.security.application-groups': ['group.cogell.gym-time.data'], }, };
{ "extra": { "eas": { "projectId": "XXXXXXXX" "build": { "experimental": { "ios": { "appExtensions": [ { "bundleIdentifier": "com.cogell.gym-time.widgets", "targetName": "widgets", "entitlements": { "com.apple.security.application-groups": ["group.cogell.gym-time.data"] } } ] } } } } }
https://evanbacon.dev/blog/apple-home-screen-widgets https://github.com/bndkt/react-native-widget-extension https://github.com/gitn00b1337/expo-widgets https://docs.expo.dev/config-plugins/introduction/
Current things that bring me joy to work on