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;