Skip to content

Add support for iOS Wifi connections #4252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
NathanaelA opened this issue Jan 2, 2019 · 9 comments
Open

Add support for iOS Wifi connections #4252

NathanaelA opened this issue Jan 2, 2019 · 9 comments

Comments

@NathanaelA
Copy link
Contributor

Is your feature request related to a problem? Please describe.
In current versions of iOS and xCode you can pair your device using Wifi; meaning you no longer need to use a USB cable. NativeScript can't seem to use this pairing; even thought xcode can.

Describe the solution you'd like
Ability to use WiFi connection for debug/install.

Describe alternatives you've considered
using Xcode. (its a pain, as you have to build via command line first, then use xcode to do everything. Any changes to JS has to be replicated back to the original folder from the platforms copy that xcode is using)

@NathanaelA

This comment was marked as abuse.

@rosen-vladimirov
Copy link
Contributor

Hey @NathanaelA ,
Please excuse me for this so delayed reply. In the next lines I'll try to explain the current way we are working with iOS Devices.

NativeScript CLI relies on iTunes binaries and methods to detect and work with iOS devices. This implementation allows us to work with iOS devices on both macOS and Windows (where iTunes binaries are available). So, whenever CLI process needs to execute some action with iOS devices or search for them, it calls some iTunes methods. As the binaries are not in JavaScript, we have implemented our own library with binary executable, which we use as a wrapper for the iTunes methods. This library is ios-device-lib. As you can see - it has JavaScript part that starts a binary executable (the source code of the executable is also in the repo) and communication between the JavaScript and the binary is through messages on stdout.

NativeScript CLI consumes the ios-device-lib library and calls the JavaScript methods. The implementation is wrapped in the ios-device-operations class.

One really specific thing that I would like to mention is the device detection - when the ios-device-lib binary is started, it automatically starts a separate thread where it executes a method called runLoopRun - this method is purely blocking and it executes the device detection, i.e. - the runLoopRun starts a process, which will exit only when the ios-device-lib binary is killed. When it detects a change in the currently attached devices (device is attached, trusted, detached), the iTunes binaries call the previously registered device_notification_callback. At this point, based on the message, the ios-device-lib binary decides what is the current operation and if it is a new detected device, it reports it to the JavaScript implementation through the stdout of the spawned process. The important part here is the on_device_found implementation, where we have excluded devices detected via Wi-fi. In previous versions, we were detecting devices connected over Wi-fi, but trying to deploy applications and livesync them led to error.
So, the first step here is to enable detecting devices over Wi-fi in the ios-device-lib (you'll have to rebuild the binary). Maybe there is a new Interface type, we've assumed 2 is Wi-fi as that's what we've found during debugging this case. After that you can try installing application on a device connected over Wi-fi (note: you can try this directly by opening the IOSDeviceLib.xcodeproj and passing commands to the stdout of the process, ping me in case you need help with this setup). Maybe our current method will work, but probably it will require finding some new methods from the iTunes binaries that will allow us to do this. After that we can continue with the other required methods.

Hope this gives enough information for starting the research. Ping me in case you have any other questions.

@vpiskunov
Copy link

Any luck with implementing this? Or perhaps some workarounds?

I was thinking to write a small utility script, to be executed after the build is complete, to use Xcode’s libraries to deploy automatically.

My worry however is that this wouldn’t have any luck with the live reloading / hot updates etc. 🤔

@ibnYusrat
Copy link

I am running Mac OS in VM Ware and as soon as I plug an iDevice, the device crashes and also the VM Crashes. This feature could really be a life saver for me (and other people in the same situation).

@vpiskunov
Copy link

@ibnYursat that probably still wouldn’t help you much. To test, open a project in Xcode and try using xcode’s WiFi deployment - my bet is, it would need direct access to device anyhow.

@ibnYusrat
Copy link

ibnYusrat commented May 29, 2019

@ibnYursat that probably still wouldn’t help you much. To test, open a project in Xcode and try using xcode’s WiFi deployment - my bet is, it would need direct access to device anyhow.

Actually I am able to deploy using X-Code. The crashing happens only when the VM is running under Linux, on Windows the USB connection works just fine, but I am a little bit uncomfortable with Windows and have it installed as a secondary OS to be used only in case of extreme compulsion.

So currently I am able to hit the 'run' button in X-Code and deploy the project on iPad or any iDevice for that matter. Problem is that there is no livesync. And to see updates, we have to build the project again and then run it.

@vpiskunov
Copy link

vpiskunov commented May 31, 2019

What I was referring to, is not the simple xcode deployment, but the "wifi deployment from xcode"

Did you test deploying wirelessly from xcode directly?

I got the impression you only confirmed xcode via usb deployment?

See this article for guidance: https://codeburst.io/wireless-debugging-ios-run-debug-install-builds-over-wifi-a48fc49ac3a7?gi=6ddab274acfb

Actually I am able to deploy using X-Code. The crashing happens only when the VM is running under Linux, on Windows the USB connection works just fine, but I am a little bit uncomfortable with Windows and have it installed as a secondary OS to be used only in case of extreme compulsion.

So currently I am able to hit the 'run' button in X-Code and deploy the project on iPad or any iDevice for that matter. Problem is that there is no livesync. And to see updates, we have to build the project again and then run it.

@ibnYusrat
Copy link

ibnYusrat commented Jun 1, 2019

What I was referring to, is not the simple xcode deployment, but the "wifi deployment from xcode"

Did you test deploying wirelessly from xcode directly?

I got the impression you only confirmed xcode via usb deployment?

See this article for guidance: https://codeburst.io/wireless-debugging-ios-run-debug-install-builds-over-wifi-a48fc49ac3a7?gi=6ddab274acfb

Actually I am able to deploy using X-Code. The crashing happens only when the VM is running under Linux, on Windows the USB connection works just fine, but I am a little bit uncomfortable with Windows and have it installed as a secondary OS to be used only in case of extreme compulsion.
So currently I am able to hit the 'run' button in X-Code and deploy the project on iPad or any iDevice for that matter. Problem is that there is no livesync. And to see updates, we have to build the project again and then run it.

I am sorry I don't think I was explicit there. Please let me explain. I have dual booted Windows and Ubuntu. I have VM Ware installed on both operating systems. On Windows, if I connect any iDevice via USB to the VM, it works. And I am able to deploy on it. But if I connect an iPhone or iPad to the VM in Ubuntu, the VM Crashes and the iPhone also crashes (simply reboots as soon as its unplugged). So the solution I found was Wifi deployment. I configured it by logging into Windows for once > plugging the device > Checked connect via network. And turned off the VM. Rebooted into Ubuntu and opened the same VM and the iDevice was still shown as connected (over wifi). So yes I meant wifi deployment from xcode works, however, it doesn't work from tns run. You see if I open X Code and my device is connected wirelessly, I am able to deploy the project on the device over wifi. But this doesn't have live sync. To see the updated app I have to manually tns build ios it (may be tns platform clean ios also in some cases) and when the process finishes, I go back to xcode and hit the 'run' button again which of course would take much longer to test the app than it would if I was running it with tns run or tns debug.

Ideally if tns device list could somehow list all the WiFi connected devices and also deploy on them, it would be perfect!

@vpiskunov
Copy link

I see @ibnYusrat, makes sense now! I'm not sure what and when we can expect on this, knowing some features take years to get to implementation. For your case, I'll suggest looking into alternative drivers, for both your Ubuntu installation, as well as the VM inside. I'm pretty sure you'll find some to try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants