From ddac17c6c531b8ce9c171baf38be4a7a8a1e38a2 Mon Sep 17 00:00:00 2001 From: Savsis Date: Fri, 8 May 2026 13:58:21 +0500 Subject: [PATCH] Add files via upload --- scripts/fix-track-player-plugin.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 scripts/fix-track-player-plugin.js diff --git a/scripts/fix-track-player-plugin.js b/scripts/fix-track-player-plugin.js new file mode 100644 index 0000000..191fe02 --- /dev/null +++ b/scripts/fix-track-player-plugin.js @@ -0,0 +1,30 @@ +/** + * Rewrites react-native-track-player/app.plugin.js to pure CommonJS + * to avoid broken lib/src imports during expo prebuild + */ +const fs = require('fs'); +const path = require('path'); + +const pluginPath = path.join(__dirname, '..', 'node_modules', 'react-native-track-player', 'app.plugin.js'); + +if (!fs.existsSync(path.dirname(pluginPath))) { + console.log('[fix-plugin] node_modules/react-native-track-player not found — skipping'); + process.exit(0); +} + +const content = `const { withInfoPlist } = require('@expo/config-plugins'); +module.exports = function withTrackPlayer(config) { + return withInfoPlist(config, function(cfg) { + if (!cfg.modResults.UIBackgroundModes) { + cfg.modResults.UIBackgroundModes = []; + } + if (!cfg.modResults.UIBackgroundModes.includes('audio')) { + cfg.modResults.UIBackgroundModes.push('audio'); + } + return cfg; + }); +}; +`; + +fs.writeFileSync(pluginPath, content); +console.log('[fix-plugin] app.plugin.js rewritten OK');