90

I have my iPhone connected to Xcode. It used to work just fine recently. I see it in the Devices and Simulators section, but when I try to compile my app, it says:

D's iPhone 6S is not connected. Xcode will continue when D's iPhone 6S is connected.

In the Devices and Simulators I see it as disconnected.

I tried restarting the phone, turning it's wifi on and off. It's connected to the same wifi network, I tried restarting Xcode, nothing. I run Xcode 9, Beta 6 at the moment. Does anyone has similar issue and hopefully know how to solve it?

6
  • Have you tried to connect it with USB or only via WiFi?
    – Xvolks
    Sep 2, 2017 at 13:48
  • If you have upgraded your phone to a former beta, you should try via USB. Beta9 erased all my music, so there are side effects.
    – Xvolks
    Sep 2, 2017 at 14:26
  • Hmm, I've upgraded to beta 9, but I didn't notice anything unusual happening in my phone. There was an issue with the usb, but now its working wirelessly. I don't get it really...
    – Dani
    Sep 2, 2017 at 14:29
  • 1
    Maybe, just connecting it with USB restored some security token that was lost with the upgrade.
    – Xvolks
    Sep 2, 2017 at 14:30
  • @Sauvage sort of. See the answer that I've posted below. I hope it helps you
    – Dani
    Sep 13, 2017 at 14:51

29 Answers 29

95

Troubleshooting:

  1. plug in your iPhone.
  2. Open Xcode
  3. go to window -> Devices and Simulators
  4. Right click on your device
  5. click Unpair Device and unplug it.
  6. restart Xcode
  7. restart your iPhone.
  8. Connect your iPhone via USB
  9. run your app
  10. then unplug it, and it should run via the wifi again.

Set up

  1. Window -> Devices and Simulators

enter image description here

  1. Choose your device from the list.

enter image description here

  1. Tick the box for "connect via network."

enter image description here

11
  • l Trial and error led me to this answer. I tried all the other answers here at the time. Mar 9, 2018 at 19:15
  • 12
    I was borrowing cables from my coworkers, then enabled wireless build, now you let me unpair the device, oh man, I'm not going to ask for a cable one more time.
    – fullmoon
    Oct 9, 2018 at 10:44
  • 4
    I just had to unpair and reconnect my phone -- didn't even have to restart anything.
    – DustinB
    Jan 8, 2019 at 16:59
  • 1
    I unpaired my devices and now it doesn't find them again using USB ... wtf... neither my iPhone nor my iPad ... Maybe it's time to reboot the MacBook Jan 11, 2020 at 9:00
  • 1
    There are times for me when that wasn’t enough. . Jul 28, 2021 at 16:12
60

In Window > Devices and Simulators, right click on your iPhone and "Connect with IP address", then enter the iPhone IP address and you're connected.

6
  • Running USB and disconnecting doesn't work for me. This looks like the way to do it then.
    – brainray
    Nov 9, 2017 at 13:10
  • Xcode Version 9.1 - no option to "Connect with IP address" - only method I could find is USB cable. Nov 14, 2017 at 12:42
  • Xcode 9.1 - reconnecting via WIFI, I have to open "Devices and Simulators" window and then Xcode will continue connecting when your device is unlocked!
    – webmastx
    Nov 15, 2017 at 13:47
  • Connect via IP address does not work for me. The only way to restore the connection is to plug USB cable, and click the checkbox "connect via network" again whenever it appears. Apr 21, 2018 at 12:54
  • 1
    This is the correct answer for when you don't actually have a lightning data cable! Jul 30, 2021 at 6:36
46

Turn off WIFI on Mac, and also on your iPhone too. Then turn on WIFI again on both devices.

I frequently face this issue since I don't use USB cable to build the app to my iPhone. So this is my usual way to resolve the connection problem.

5
  • I've had some luck doing this but does not work for me most of the time.
    – Jeremiah
    Jan 7, 2019 at 20:18
  • 4
    Quickly turning off and back on macOS wifi via the menu bar has worked every time for me, and the problem occurs less frequently. Sep 3, 2020 at 14:03
  • Works for me either. No need to turn something off. It'll even continue deploying to your device after it finds it on the network. Jun 25, 2021 at 8:42
  • 1
    I've Unpaired and restarted Xcode and the phone but no result. Disabling and enabling Wifi fixed it. Thanks!
    – Berik
    Jan 1, 2022 at 22:22
  • Works for me. Thanks ! Jan 18, 2022 at 15:49
27

As Sam H.'s answer, can Connect via IP Address. This is XCode 9 or 9.1 's function. And need your device update to iOS11 +

enter image description here

0
14

Apparently, more people have this issue. The only "solution" I found was to connect the iphone with a USB, run the app and then try to run it using wifi. This usually solves my problem.

8

Restarting the wifi on my Mac worked for me.

1
  • This worked for me also, turning WiFi off on both the Mac and iPhone and then back on worked first time. The simplest things are usually overlooked. Thanks.
    – David_2877
    Jul 21, 2020 at 6:38
8

You can also connect via IP address

While Xcode is open, go to

Windows -> Device and Simulators

right click your device and connect via IP address. You can get your phone IP address from settings under wifi and clicking the info button on the network.

7

I was able to reconnect using this method:

  1. Disconnect/Unplugged the device from Mac
  2. Close X-Code
  3. Run "sudo pkill usbmuxd" in terminal
  4. Reopen Xcode
  5. Reconnect Device

Try this if unpairing method does not work.

2
  • Thanks it works. Can you explain the process ? What is usbmuxd ?
    – ReaperSoon
    May 16, 2022 at 12:30
  • @ReaperSoon it is a socket that operates the connections from and to iOS devices Mar 7 at 15:53
6

I'm using Xcode 9.1 and suddenly had this issue.After reading other answers a realized it is a Xcode bug via wifi debug.My solution was to connect the iphone with a USB, then go to the Add Additional Simulators,then come to the interface below,uncheck "connect via network". Problem sovled,and back to debug via a USB.

enter image description here

3
  • If this option does not appear, try to reattach your device. Nov 28, 2017 at 7:22
  • For me nothing worked. I tried to connect via network, via IP, via usb cable. 20 times each. None worked. iOS development does not work very well. Dec 10, 2017 at 21:34
  • Without doing any plugging in or out this issue suddenly occured. Your answer resolved it, thank you! Nov 7, 2018 at 17:56
4

Making Cellular data Off solved my problem

2
  • In my scenario I haven't used the cellular even :(
    – MGY
    Jan 22, 2019 at 8:28
  • I also had to turn off Cellular data, but once the connection was successful with Xcode, I was able to turn back on Cellular data, and the wireless connection to Xcode still worked. Jun 29, 2021 at 16:34
3

I had this issue when I changed my network connection on my Mac and in this case reconnecting the phone with an USB cable doesn't work. I had to restart xCode.

3

Make sure your Mac and device connected in same network(Wi-Fi) connection.

1
  • My problem was a kind of variant of this - my laptop was not connected to WiFi, the iPad was. When I reconnected the the Mac to WiFi, the device preparation started working (before it was giving me a "failed to prepare" error in a loop). Sep 14 at 5:07
3

I had to update Xcode in my case. I tried literally everything else in this thread.

1
  • Yeah, they should consider displaying an "Update Xcode" message instead of "Device not connected" in the pop-up that appears when the app fails to run. I found out the issue after viewing the logs in Window -> Devices and Simulators
    – Kewal Shah
    Dec 22, 2020 at 9:23
2

I had to reopen Xcode with my iPhone X unlocked and then I had to open Windows->Devices immediately afterwards.

Then the message was changed into:"iPhone X is busy: Preparing debugger support for iPhone X"

2

Also make sure your iOS device is on the same wifi network as your Mac, otherwise Xcode will insist you connect your device via USB, even if you've checked the box to use wireless development for that device.

2

There could be more than one reason why xcode forgets the device often. One of them could be the dynamic IP which is assigned automatically.

Apart from general troubleshooting (device is unlocked etc), here are few suggestions based on my experience.

1) Check if you are using the SAME WIFI on computer and device.

2) In Xcode > Devices and Simulators > Right Click > Unpair Device and connect again.

3) Prefer to use static IP. At least for the device (Give Manual IP address in the iPhone).

4) In Xcode > Devices and Simulators > Connect via IP Address

5) Use USB cable to run the app and then unplug to use wireless solves it most often.

6) Disconnect and Reconnect Wireless on Computer & Mobile Device

7) Turn off the Cellular Data

8) Turn off any VPN you are using.

9) Check your Network Settings on Computer and Device. Disable any suspecious setting (Proxy etc).

10) Restart Device and Computer. It often resolves few network interface problems.

2

In my case a pending software update on my iPhone was preventing it from accepting new builds from Xcode - even over USB.

I tried all the other suggestions in this thread and nothing worked, but accepting the pending update on my phone fixed the problem.

2

Apparently the Apple engineers don't really have networking under control.

Typically, a dance of (in the order of increasing inconvenience)

  • Toggling "Connect via Network"
  • Toggling "WiFi" on Mac and iPhone
  • Unpairing + Repairing the device in the Xcode organizer
  • Restarting (yes, just like Windows) the Mac and the iPhone

works for me.

1

This is just to add the other possible reasons that the answers forgot to mention:

You got a new phone and Xcode is trying to connect to the old phone: Window<< Devices and Simulators: Press the + button and connect your phone via usb cable and click
your on your device. It should add it at that point.

You could also try running bluetooth instead of wifi, but it might still do the same problems. Make sure your device is connected correctly

1

1 - Go to Xcode - Window - Device and simulator - Unpair device 2 - Xcode and Mac both are restart and open Xcode again and connect your device Via USB cable and run it.

1
  1. Restart Xcode & if issue persists do steps 2-4.
  2. Open Devices and Simulators window in Xcode (shortcut is ⌘⇧2 command+shift+2)
  3. Make sure your device is active (press home button & enter passcode if needed)
  4. Open terminal & run netstat command.

You device will be reconnected

1

I had to reset the trusted computers from phone settings -> Developer -> "Clear Trusted Computers". Then it worked.

0

Just in case someone did what I did: I used to have wireless connection with my mac mini but one day I decided to use a cable. From that day I had problems with my devices, I always had to use usb the first time I opened Xcode. When I removed cable connection everything worked fine as before.

0

I tried a combination of the above solutions and can't pinpoint what solved it.

When Xcode was stuck on trying to connect to my wireless iPad, I had to do was start browsing with Safari on my iPad. I think that somehow refreshes the network on the iPad.

The Xcode's 'Device and simulator' may not properly reflect the connection status between the device and mac so after browsing with your iPad/iPhone hit run on Xcode and then just wait till they find each other

0

I had the same problem yesterday/today. Tried the various suggestions here but none worked. Except maybe, restarting the iPhone. I was able to install my app!!

Previously I had a Xcode/iOS version mismatch but currently at 12.2/14.2 which should and finally did work.

0

My problem was actually the cable itself, seems that some of the cheap cable you buy might not work 100% with your ipad/iphone. Try with a different cable

0

You must put a passcode on the device, otherwise wifi debugging will not work.

0

Unlock your iPhone or iPad (helped me).

0

I also keep running into this problem with Xcode 15 running on M1 MacBook Air and iPhone 11 running iOS 17.

One or all of these steps always solves it for me:-

  1. If you have a VPN, try turning it off once and see if it connects. I use Nord VPN and its threat protection seemed to have prevented Xcode from connecting to the iPhone. If that wasn't the issue, keep reading.
  2. Use a Mac App named DevCleaner for Xcode. This app is actually for cleaning up space after app development. But for some reason that I'm not too sure about, cleaning all the components shown in this app often solves the above problem.
  3. Then, in Xcode, Go to Product -> Clean Build Folder... then restart Xcode.
  4. In the iPhone, go to Settings -> Privacy and Security -> Developer Mode. Turn it off then on again. The phone will restart and ask permissions to switch developer mode ON and Trust the MacBook again.
  5. At this point if you see the device list in Xcode, you will see that Xcode is preparing the phone for development (copying files between the Mac and iPhone, etc.)

And that's it. You should be able to get back to work on your apps. Let me know in the comments if this isn't working.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.