0

I'm running Expo on my Mac for developing apps.

I want to connect my iPhone, which runs my own app I'm developing, to the Expo server using USB tethering only - as I haven't got a SIM card and WiFi is not an option either.

How can I accomplish this?

Update:

I can turn on internet sharing for "iPhone USB" but it doesn't appear under "Preferences -> Network" Here's the ifconfig output when I connect my iPhone in this entry gets added:

en33: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=400<CHANNEL_IO>
    ether a2:99:9b:92:ba:7c 
    inet6 fe80::80b:d418:2177:9032%en33 prefixlen 64 secured scopeid 0x9 
    inet 169.254.246.125 netmask 0xffff0000 broadcast 169.254.255.255
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect (100baseTX <full-duplex>)
    status: active

In Sharing "Share your connection" I set it to Ethernet and wifi both gave the same ip.

5
  • 2
    What are you trying to do? iOS does not give any access to any built in web server. What is "adb?" And you can tether an iOS device to a Mac or PC via USB so you can use the phone's internet access. But with no cell or WiFi available... BTW we don't support or troubleshoot jailbreaking here, so those questions will remain unanswered? Commented Sep 21, 2021 at 18:00
  • There is a local server is running on my pc, iPhone can connect to it and use it in the apps I build for ios, ( I'm an app developer), adb is android debugging bridge it let's you do a lot by just connecting your andorid phone to your computer, such as port forwarding.My phone is not jailbroken I just wanted to mention if it's needed for this task I'm open to it, thank you for your answer, if anything is still unclear please let me know. Commented Sep 21, 2021 at 18:38
  • 1
    TheWhy not use a gigabit Ethernet to get the phone on your local network? That is high performance wired networking and means you don’t have to juggle routing tables on your computer… We find this superior for developing on iPad and iPhone to lightning to host in almost all situations.
    – bmike
    Commented Sep 22, 2021 at 11:29
  • Because as I already mentioned this is not for personal use, and since not everyone buys hardware for this, this is not going to be a good solution, for personal use however your suggestion is great! Commented Sep 22, 2021 at 15:46
  • 1
    Downvotes can be given for a lot of reasons. In the case here it may reflect the fact that the question got difficult to understand after all the updates, and that essential aspects of the question seem to only have surfaced after people answered based on the available facts. It usually helps to ask focused questions and, if necessary, ask follow-up questions (instead of detailled discussions in the comments).
    – nohillside
    Commented Sep 22, 2021 at 17:24

3 Answers 3

4

This is really quite simple - just plug the phone via a Lightning to USB cable into the Mac to get a network connection.

The network connection will be between the iPhone and the Mac only. It is not by default an internet connection for the phone, but that is not needed for Expo development.

On the Mac in System Preferences > Network, you'll see the phone listed as "iPhone USB". Click on "iPhone USB" and you'll see the phone's IP-address.

If you have other means of connection enabled on the phone, you might need to remove the checkmark from "Disable unless needed" and click Apply - but apart from that, you automatically have a network connection to the Mac now.

If you're running a macOS version where you do not see it in the graphical interface, you can instead run this Terminal command:

ifconfig

Compare the output before and after plugging in the iPhone, and you'll see that a new network interface named "enXX" (where X's are numbers) appears after plugging in the iPhone. The IP address listed is the IP address of your computer in this private network.

Now to make sure that the Expo server uses this private network instead of your WiFi for communicating with the phone, you set its initial interface like this in the Terminal:

export EXPO_DEVTOOLS_LISTEN_ADDRESS=169.254.246.125
export REACT_NATIVE_PACKAGER_HOSTNAME=169.254.246.125
expo start

Replace 169.254.246.125 with the actual IP address you see listed for your computer.

If you also want to share the internet connection of your Mac with the phone, you can do that from System Preferences > Sharing > Internet Sharing. This enables NAT, so you will experience that the interface on your Mac, as well as the interface on your iPhone, now have different IP addresses, and you'll need to update the commands above accordingly.

0
3

I'm a little unsure if this is what you're looking for, but...

To get internet on an iPhone without Wi-Fi or Cellular data, you can buy a USB to Ethernet adapter that works with iPhone and connect to a standard ethernet cable:

Lightning to Ethernet (directly): https://www.belkin.com/us/adapters/ethernet/ethernet-power-adapter-with-lightning-connector/p/p-f8j227/

Lightning to USB to Ethernet (Apple made adapters, cheaper, 100Mb/s):

Amazon Basics gigabit adapter is reasonably priced and works very well.

0
2

You basically want some apps you are developing to connect to a web server locally on your PC.

All you need to to do is to create a Wireless Local Area Network (LAN) beween your PC and iPhone using a WiFi router. That's it. Once both the PC and the iPhone are connected by Wifi to the router, your iPhone apps should be easily able to communicate with the web server on your PC using the PC's local IP address.

If you don't want to use a router, and connect your iPhone directly to your Mac, just activate Wifi Hotspot on your Mac using "Internet Sharing", and connect your iPhone directly to it through wifi. To do this on your mac, go to System Preferences > Sharing > Internet Sharing (More details here - share the Internet connection on Mac with other network users).

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .