Created
June 20, 2025 18:08
-
-
Save Randall71/695f5ced1123dcce484b985484a2a167 to your computer and use it in GitHub Desktop.
Config Plugin to just build expo app for specific architectures of processor (armeabi-v7a, arm64-v8a, x86, x86-64)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { withGradleProperties, withAppBuildGradle } = require('@expo/config-plugins'); | |
| const withAbiFilters = (config, { abiFilters = ['arm64-v8a'] } = {}) => { | |
| console.log('🔧 ABI Filter plugin is running!', abiFilters); | |
| // Set gradle.properties | |
| config = withGradleProperties(config, (config) => { | |
| // Convert array to comma-separated string for gradle.properties | |
| const architecturesString = abiFilters.join(','); | |
| // Set the reactNativeArchitectures property | |
| config.modResults = config.modResults.filter( | |
| (item) => !item.key || item.key !== 'reactNativeArchitectures', | |
| ); | |
| config.modResults.push({ | |
| type: 'property', | |
| key: 'reactNativeArchitectures', | |
| value: architecturesString, | |
| }); | |
| return config; | |
| }); | |
| // Set build.gradle ndk.abiFilters | |
| config = withAppBuildGradle(config, (config) => { | |
| const abiFiltersString = abiFilters.map((abi) => `"${abi}"`).join(', '); | |
| // Add ndk abiFilters to defaultConfig | |
| if (config.modResults.contents.includes('defaultConfig {')) { | |
| config.modResults.contents = config.modResults.contents.replace( | |
| /(defaultConfig\s*\{[^}]*versionName\s+[^}]*)/, | |
| `$1 | |
| ndk { | |
| abiFilters ${abiFiltersString} | |
| }`, | |
| ); | |
| } | |
| return config; | |
| }); | |
| return config; | |
| }; | |
| module.exports = withAbiFilters; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks!