I am developing a react-native
mobile application and testing on both Android and iOS simulators at the same time. The thing is when we run npx react-native start
it starts the metro bundler
and then asks for android
or iOS
commands. When we select one of them it starts the app and prints logs for it but when at the same time we start the other it gives logs in the same terminal window. This way I am not able to figure out from which platform the logs are coming.
I want to view both platform logs differently. Is there a way or other methods to print logs separately?
2
Answers
TLDR; You can change the port number for iOS and keep the same port for android. Then run two terminals with each and you should be able to see logs separately.
Run for android
Running different for the iOS
Go to your ios/[projectName].xcodeproj/project.pbxproj file and
search for 8081.
Replace it with 8082
then go to different terminal than the one running android and do yarn start –port 8082
The quickest way, in my opinion, would be to use the
Platform
method fromreact-native
.UseCase