🌐 To run a script (or some part of a script) only for Android or iOS builds, you can fork the behavior depending on the platform within the script. See the following common examples to do this through a shell script or a Node script.
#!/bin/bash# This is a file called "pre-install" in the root of the projectif[["$EAS_BUILD_PLATFORM"=="android"]];thenecho"Run commands for Android builds here"elif[["$EAS_BUILD_PLATFORM"=="ios"]];thenecho"Run commands for iOS builds here"fi
🌐 The following script installs git-lfs if it is not yet installed. This is useful in some cases where git-lfs is required to install certain CocoaPods.
pre-install
if[["$EAS_BUILD_PLATFORM"=="ios"]];thenifbrew list git-lfs > /dev/null 2>&1;thenecho"=====> git-lfs is already installed."elseecho"=====> Installing git-lfs"HOMEBREW_NO_AUTO_UPDATE=1brew install git-lfs
git lfs install
fifi
// Create a file called "pre-install.js" at the root of the projectif(process.env.EAS_BUILD_PLATFORM==='android'){console.log('Run commands for Android builds here');}elseif(process.env.EAS_BUILD_PLATFORM==='ios'){console.log('Run commands for iOS builds here');}