I configured Metro to run React Native packager/bundler on a different port as 8081 is being used by McAfee service and I can't kill this process on my Mac.
I changed the default port to different one in Xcode script/files etc. But the react metro server(packager/bundler) i had to manually start every time before running the App. However with following edit in your MetroConfig.js file, if you run the App, then Metro server will automatically run on a different port specified in this file
const { getDefaultConfig } = require('expo/metro-config');
const portConfig = getDefaultConfig(__dirname);
portConfig.server.port = 8088;
module.exports = portConfig;
Thank you!
Sorry! My code is correct... it wasn't working yesterday because of some other issue. Once i fixed that, this config is working fine :)
Before customizing Metro file, I had to manually start Metro Packager(from the terminal) whenever I was launching the React Native App from Xcode. However once I configured the Metro, the Packager/bundler is starting automatically when I run the App from Xcode... so all good now!