I want to build a LAN between the iPhone and the Mac connected for development.

Asked 1 years ago, Updated 1 years ago, 40 views

I am developing an iOS app and an api server that communicates with it on a mac.Usually, it was a simulator-based development, and at that time, I used to refer to the api server that I set up in localhost, so it worked without any problems.I wanted to check the behavior of the actual machine, so when I tried to connect my iPhone to a mac and run the app, I realized that the host that gets the api had to specify a mac instead of a localhost.

When specifying the IP of a mac, I confirmed that if I connect the iPhone to the LAN where the mac is now connected, and bind the private IP on the application, and the api server at 0.0.0.0 it will work, but I didn't want to do this much if I was working in a shared office or cafe.

Question:

    From
  • mac, when you deploy an app to the iPhone for verification, can you build a LAN and build a network that can only be accessed from the iPhone?(Or is there a way to specify a host's mac in a way that can be resolved on the connected iPhone?)

ios macos network

2022-09-30 11:27

1 Answers

There are two possible ways.
Method 1: How to check the IP address assigned to a Mac from the terminal app with "ifconfig" and change the iOS app source to that IP address each time
Method 2: How to connect a Mac using Internet sharing as a Wi-Fi router

Method 1
1)Connect to any cafe or share office.
2)Launch the terminal app from your Mac and run the ifconfig | grepinet command
3)This will list the IP addresses that Mac has, so I will specify that IP address as the IP address of the iOS application API server.

There are often multiple IP addresses, but I think most IP addresses that start with 192.168. or 10. should be used.

Method 2
1)Connect to any cafe or share office.
2)Use the following URL http://omomukibukai.com/mac-router/ to turn your Mac into a Wi-Fi router.
 Detailed instructions are quoted below.

1. Select System Preferences
2. Select Share (right end of 3rd stage)
3. Select Internet Sharing from the list of services on the left side of the screen
4. From the list of ports on the right side of the screen, select WI-FI and select the WF-FI option under the box.
5. Set the network name, channel, security, and password.
6. Finally, check the Internet share in the "Share" service list and finish.

3) Connect to the wifi you created here with your iPhone device.(If you do not want to automatically recognize it, please set it manually.)
4)If the connection is successful, tap Settings App > Wi-Fi > Connected wifi and the IP address of the router displayed there should be the address of the Mac address.
5)Set the IP address of the router to the address of the iOS app API server.

By the way, if you don't set up an API server on your Mac and rent it to an API server, you might want to be able to connect from anywhere

How about that?


2022-09-30 11:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.