Skip to content
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

'iosHost' config option to allow changing figwheel websocket host #26

Closed
gnl opened this issue Feb 28, 2016 · 15 comments
Closed

'iosHost' config option to allow changing figwheel websocket host #26

gnl opened this issue Feb 28, 2016 · 15 comments

Comments

@gnl
Copy link

gnl commented Feb 28, 2016

Currently there is no easy to set the figwheel websocket url to anything other than 'ws://localhost:3449' which would be very helpful for live code reloading on an iOS device.

I tried changing the :websocket-url in env/dev/env/ios/main.cljs, but the localhost URL still ends up in:

ios/figwheel/connect.cljs
target/ios/figwheel/connect.cljs

I'm not familiar enough with the code base/figwheel/compilation process and wasn't able to find a quick solution. Help! :)

P.S. Awesome project!

@gnl
Copy link
Author

gnl commented Feb 28, 2016

Adding this to project.clj didn't help either:

:figwheel {:websocket-url "ws://<my-ip-address>:3449/figwheel-ws"}

@cldwalker
Copy link

I just made live reloading on a iOS device work by changing references to localhost to MYIP in AppDelegate.m, index.ios.js and env/ios/main.cljs.

To make this easier I'd propose a use-ios-device command that like the android command has a key in .re-natal and updates these files. iosHost would default to localhost like androidHost. @drapanjanas Does this approach sound reasonable? If so, I'm happy to make a PR

@drapanjanas
Copy link
Owner

I have no iOS device so will not be able to help much... so live coding does not work when you connect usb right? Or do you use wifi? For example, on android device localhost works fine when connected via usb, but to use simulator you need to use special IP.
@cldwalker yep we could introduce use-ios-device. Too bad we need to change AppDelegate.m, but that is easy with regex. So what would be the interface? Smth like re-natal use-ios-device my.ip.addr? or you have something else in mind? I guess we even could resolve ip if not specified but that is more nice to have feature. I will be glad to merge PR for this.

@drapanjanas
Copy link
Owner

Or re-natal use-ios-device real|simulator? 'simulator' parameter would set the localhost and 'real' would resolve and set your en0 ip. What do you think?

@gnl
Copy link
Author

gnl commented Feb 28, 2016

re-natal use-ios-device with similar behaviour to the android command sounds great, but we should definitely have a parameter for the exact IP address - on machines with multiple network interfaces (like mine) en0 might end up being the wrong interface.

And I'm connecting through wifi, I don't think there's any way to do it over USB (even though it would be nice, but that doesn't seem to set up any kind of network interface).

@cldwalker
Copy link

@drapanjanas My ios device connects through usb. re-natal use-ios-device real|simulator sounds good. I would use ipconfig getifaddr en0 to get the IP for device. I agree with @gnl that we should also allow IP. If the value isn't 'real' or 'simulator' we could just substitute with the given arg/IP. Sound good?

@gnl
Copy link
Author

gnl commented Feb 28, 2016

@cldwalker - I'm pretty sure I edited the exact same files (AppDelegate.m, index.ios.js and env/ios/main.cljs) and I also set the :server-ip figwheel option to 0.0.0.0 to get figwheel to listen on all interfaces.

I was able to connect and get the app to run (the connection to the react packager worked just fine) but there was no connection to the figwheel repl (started with rlwrap lein figwheel ios) and thus no live reloading.

A tcpdump on port 3449 showed no connection attempt from the figwheel client (running on my iphone) and looking at the compiled files I mentioned in my first comment, the settings didn't seem to have any effect, the websocket url was still pointing to localhost.

@cldwalker
Copy link

@drapanjanas And yes live coding iOS device live coding doesn't work until I changed those three files

@drapanjanas
Copy link
Owner

@gnl I agree, we should be able to set an exact IP address. I will also implement the same for android afterwards. Feel free to design and submit the PR for use-ios-device command! @cldwalker yes, sounds great!

@gnl
Copy link
Author

gnl commented Feb 28, 2016

Great, thank you!

@drapanjanas
Copy link
Owner

@gnl have you tried to restart packager after you have changed all these files? I sometimes experienced that my changes of index.ios.js was not active for some reason.

@gnl
Copy link
Author

gnl commented Feb 28, 2016

@drapanjanas - yes, tried pretty much every possible combination of restarting the packager, including with the --reset-cache option and cleaning / rebuilding the cljs build, nothing.

@gnl
Copy link
Author

gnl commented Feb 28, 2016

It's certainly possible that I might have missed something, so I'll just test again and help debug if there's any issues after @cldwalker submits his pull request.

@gnl
Copy link
Author

gnl commented Feb 29, 2016

Just tried this again - editing/confirming the edits in AppDelegate.m, index.ios.js and env/dev/ios/main.cljs, resetting the packager cache and doing a clean build and I can confirm now that live code reloading works with an ios device. I can't think of anything I did differently before, but I guess I must have missed something.

@gnl
Copy link
Author

gnl commented Mar 6, 2016

Works great, thank you!

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

No branches or pull requests

3 participants