From e17c4c6854db63391c13256eac2790ce4880b694 Mon Sep 17 00:00:00 2001 From: Sean O'Connor Date: Tue, 23 Jun 2026 01:12:19 -0400 Subject: [PATCH] Sync ExpoWidgetsTarget version and build number with the main app on prebuild. Fixes App Store Connect warnings when the widget extension CFBundle version does not match the containing application. Co-authored-by: Cursor --- app.json | 1 + plugins/withSyncWidgetVersions.js | 34 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 plugins/withSyncWidgetVersions.js diff --git a/app.json b/app.json index bc12550..52ac725 100644 --- a/app.json +++ b/app.json @@ -64,6 +64,7 @@ "bundleIdentifier": "com.beenvoice.app.ExpoWidgetsTarget" } ], + "./plugins/withSyncWidgetVersions.js", [ "expo-local-authentication", { diff --git a/plugins/withSyncWidgetVersions.js b/plugins/withSyncWidgetVersions.js new file mode 100644 index 0000000..dd606bf --- /dev/null +++ b/plugins/withSyncWidgetVersions.js @@ -0,0 +1,34 @@ +// @ts-check +const { withXcodeProject } = require("@expo/config-plugins"); + +/** + * expo-widgets seeds ExpoWidgetsTarget with hardcoded MARKETING_VERSION/CURRENT_PROJECT_VERSION + * and does not update them on later prebuilds. App Store Connect warns when the extension + * does not match the containing app. + */ +/** @type {import('@expo/config-plugins').ConfigPlugin} */ +function withSyncWidgetVersions(config) { + return withXcodeProject(config, (config) => { + const marketingVersion = config.version ?? "1.0.0"; + const buildNumber = config.ios?.buildNumber ?? "1"; + const project = config.modResults; + const configurations = project.pbxXCBuildConfigurationSection(); + + for (const key of Object.keys(configurations)) { + const buildConfig = configurations[key]; + if (!buildConfig?.buildSettings) continue; + + const bundleId = buildConfig.buildSettings.PRODUCT_BUNDLE_IDENTIFIER; + if (!bundleId || !String(bundleId).includes("ExpoWidgetsTarget")) { + continue; + } + + buildConfig.buildSettings.MARKETING_VERSION = marketingVersion; + buildConfig.buildSettings.CURRENT_PROJECT_VERSION = buildNumber; + } + + return config; + }); +} + +module.exports = withSyncWidgetVersions;