Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ export default {
githubUrl: 'https://github.com/wyne/scorepad-react-native',
owner: 'wyne',
plugins: [
// Listed BEFORE expo-splash-screen: Expo runs the most recently registered
// mod first, so an earlier-listed plugin's withAndroidStyles mod runs LAST,
// i.e. after expo-splash-screen has written its style items.
'./plugins/withAndroidSplashNoIcon',
['expo-splash-screen', {
backgroundColor: '#F2F2F7',
dark: { backgroundColor: '#000000' },
Expand Down
37 changes: 37 additions & 0 deletions plugins/withAndroidSplashNoIcon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { withAndroidStyles } = require('expo/config-plugins');

/**
* expo-splash-screen always writes a `windowSplashScreenAnimatedIcon` item that
* points at `@drawable/splashscreen_logo`, even when the splash config only sets
* a `backgroundColor` (no image). With no icon image configured, that drawable is
* never generated, so a clean Android prebuild fails resource linking with:
* error: resource drawable/splashscreen_logo not found
*
* We intentionally use a color-only native splash (the animated logo is handled in
* JS by src/components/SplashOverlay.tsx), so this plugin strips the dangling icon
* reference after expo-splash-screen runs. It MUST be listed AFTER
* 'expo-splash-screen' in the plugins array so its withAndroidStyles mod runs last.
*/
module.exports = (config) =>
withAndroidStyles(config, (config) => {
const styles = config.modResults.resources.style ?? [];
let removed = false;

for (const style of styles) {
if (!Array.isArray(style.item)) continue;
const before = style.item.length;
style.item = style.item.filter(
({ $ }) => $.name !== 'windowSplashScreenAnimatedIcon'
);
if (style.item.length !== before) removed = true;
}

if (!removed) {
throw new Error(
'withAndroidSplashNoIcon: did not find a windowSplashScreenAnimatedIcon item to remove. ' +
'Ensure this plugin is listed after expo-splash-screen.'
);
}

return config;
});
Loading