Nativescript-cli: tns run command refreshes both platforms

Created on 8 Feb 2018  路  7Comments  路  Source: NativeScript/nativescript-cli

Did you verify this is a real problem by searching the [NativeScript Forum]

Yes

Tell us about the problem

I usually work on both iOS and Android devices. Both devices work at the same time. If I run tns run android command without making any changes to the code, iOS app is also refreshed. Opposite of this is also true.

Which platform(s) does your issue occur on?

Both

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.4.0
  • Runtime(s): 3.4.1 for both platforms

Please tell us how to recreate the issue in as much detail as possible.

Start an iOS or an Android device/simulator. While it is working, open another terminal and run tns run for other platform. Other one is also refreshed without any code change.

question

Most helpful comment

@Plamen5kov I didn't know that and didn't see it in the documentation. I will try it. Thanks

All 7 comments

Hi @erkanarslan,
If I understand you correctly you start tns run command for both platforms at the same time and the application will be refreshed on both, when you make some changes in the application.

This is expected behaviour. While you starting the second tns run command, the previous one will keep running and the changes will sync on the Android device as well as the iOS one.

Regarding that, it would help if you provide some more info about the case and why you think that this is a bug?

@tsonevn This is not what I meant.

I run tns run ios and start my app on an iPhone. While it is running, I run tns run android command. I didn't make any changes to the code between running these two commands. But when android application starts, iphone app is also refreshed. There is no code change.

Then, if I stop tns run ... command by hitting Ctrl + C and run it again for a device, other device refreshed again. This shouldn't happen.

Hi @erkanarslan ,

This behavior is known and expected. The reason is that when you start tns run ios this starts a watcher in the app/ folder. The moment you start tns run android in another terminal you start another watcher in the same folder. When the second watcher is started it modifies the file's access time or modify time (I'm not sure which one) and it causes the first watcher to trigger.

Thanks for your response. This shouldn't be an expected behavior. Why does a watcher need to change file dates? Only we should change them and watchers should just watch and refresh.

Hi @erkanarslan,
If you want to develop for ios and android at the same time I'd suggest using the tns run command. This command should start the application on both the ios simulator and an android emulator.
Keep in mind that the command won't start the emulator/simulator for you, they need to be already running.
This is an alternative and the recommended way to develop for both platforms at the same time instead of running two separate commands on two terminals.

@Plamen5kov I didn't know that and didn't see it in the documentation. I will try it. Thanks

Hi @erkanarslan,

The documentation is already fixed so I'm closing this issue. Fell free to reopen it and/or open an another issue in case you have some problems.

Was this page helpful?
0 / 5 - 0 ratings