Xcode error: Failed to prepare device for development - ios

I have updated to Xcode 12.3 beta. device version is 14.2, but Xcode complaining:
Errors were encountered while preparing your device for development. Please check the Devices and Simulators Window.
Failed to prepare device for development
iPhone directly connected to MacBook.
I have tried all mumbo jumbos on the web. but no success any idea?
Unable to prepare DEVICE for development
Please check the connection to the device, and review all errors in the Devices and Simulators window.

A simple phone restart will fix it
I have had to come back to this SO question twice in the past couple weeks. First time, I did have to update my Xcode and iOS versions, which fixed the issue. Now, the issue has returned, but there are no updates. I tried disconnecting and reconnecting my phone from my laptop, but to no avail.
What fixed it the second time was merely restarting my phone. I am curious if that would have fixed it the first time too, without needing to have updated.
I know this is just echoing the other answers here, but at the very least, I would recommend just starting with a simple phone restart and seeing if that fixes your problem. Here is the specific screenshot that I encountered, in case yours is the same (pro tip: you can open up the "Devices and Simulators" window by going to Window -> Devices and Simulators shift-command-2).

This error shows because of iPhone OS version is not supported by Xcode that's why this warning popped up, so check which max ios version is supported by Xcode which you are using.
In my case, the Xcode version is 13.1 and my iOS version is 15.4 so what I did, First downloaded device support version 15.4 from here (Download according to your device version) and added this to my Xcode.
steps to add the file in Xcode:-
Go to Applications > Right click on Xcode and Select Show Package Contents > Contents > Developer > Platforms > iPhoneOS.platform > DeviceSupport.
Extract your device support file to DeviceSupport Folder.
Restart Xcode and unplug and plug in your device.

Exact same problem here, this solved the issue for me:
Delete the app from the phone
Clean the Build Folder with: ⌘ + shift + K
Delete derived data
Unpair device (from ⌘ + shift + 2 window)
Disconnect iPhone
Restart iPhone
Restart Mac
Trust
After this, it worked for me.

I restarted my iPhone(14.2); now both Xcode 12.3 beta and 12.2 can run app on my device.

I could not get the phone to authorize until I had the paired Apple Watch trust the computer as well.
A more helpful error message could be imagined.
Both the iPhone and the paired Apple Watch must trust the computer before the phone can be successfully prepared for development.

If u are looking this because, your ios 15.7 device (latest for iPdas at the moment) show this error on xcode 14.0 (latest at the moment) it is a bug related with the xcode version.
Check Here.
Update
This issue is fixed in Xcode 14.0.1

In my case was to keep the iOS version with my Xcode version in sync.
Xcode 12.3 with iOS 14.3

What worked for me was to go to Xcode Devices and Simulators window, then ...
right click on the Connected device, and select "Show Provisioning Profiles" menu item, then delete all the provisioning profiles,
right click on the Connected device, and select "Unpair Device" menu item
Unplug and reboot the phone

I tried most suggestions here. The only thing that ended up working was unpairing my phone in Xcode then unpairing my apple watch from my iPhone. Connects just fine now. iOS (14.3) Xcode (12.3)

Thanks Matt for hint:
Updating device iOS to 12.3 beta fixed the problem.
if you updated you iOS to latest beta version, you should also use latest Xcode beta version.

Exact the same problem with Xcode 12.3 beta ; for me, just have to:
Disconnect the phone
Restart the phone still on ios14.2

-> data cable off
-> data cable on
and it works :)

Solution: Update your Xcode to a newer release date than your iOS Release Date.

I experienced this problem when using the iPhone's personal hotspot on my Mac. The fix was to disconnect the phone from the computer, then disconnect from the personal hotspot and reconnect again. Apparently this makes the mac use the wifi hotspot (and not the usb hotspot on the iPhone, which messes things up when debugging).

As many people mentioned/suggested, restarting my iPhone solved the problem.
My setups are: Catalina 10.15.7, Android Studio 4.0, Flutter 2.01,and Xcode 12.4.

I think having an apple watch paired to your iphone causes some issues.
I had trusted from my apple watch, but was still having this issue. Unparing my apple watch from my iphone was the only thing that worked for me:
unpair apple watch from iphone
unpair iphone from xcode
Restart both, and don't pair apple watch until the iphone is paired.
and, if you have any other problems, and are using flutter, run flutter doctor, and ensure you have cocoapods installed.
and once again, if Flutter issues, follow the details here to ensure you have your signing setup correctly
also, if things aren't working, then do a flutter clean, and then try again.

Updating Xcode is a fix because old versions of Xcode can't talk to new versions of iOS (see https://developer.apple.com/support/xcode/ for compatibility).
If you're stuck on an old version of Xcode you can use something like https://github.com/iGhibli/iOS-DeviceSupport or https://github.com/filsv/iPhoneOSDeviceSupport which installs the newer device support files into older versions of Xcode.

I just solved my issue removing the iPhone cable and putting it back.

This solved the issue for me:
Delete the app from the phone
Clean the Build Folder with: ⌘ + shift + K
Unpair device ⌘ + shift + 2
Disconnect iPhone

cmd + shift + 2
Click the red cross to check error detail
In most cases, the error message shows your xcode supported iOS version is lower than your iPhone's iOS version.
Update your xcode.

In my case, after updating iPhone to a newer iOS version then got this issue.
The solution is needed to update XCode to the latest version and everything is ok.

If other answers don't work, try updating Xcode.
For me I was using Xcode 14.0.0. The release notes for 14.0.1 say
This update fixes an issue that prevents development with devices running iOS 15.7.
Indeed my phone is on iOS 15.7.

Nothing from the above listed helped me and also I have encountered this problem when the app was removed for a while. But turning off the phone for 10 mins solved the problem.

My Current Setting and Versions:
XCode 12.4 and iOS 14.4
I had to update XCode since my iOS was updated. This fixed the compiler error in Unity and then the same message popped up during deployment. All I did was disconnect/re-connect.

Restarting the iPad works for me every time!

We encountered this error and determined it was due to a damaged iPhone cable. New cable, problem solved.

I just had to unpair the phone from Xcode's Devices and Simulators screen and then tap Trust when connecting it to the computer to make my Watch work with Xcode

I had to change the iOs Deployment target to "iOs 15". Then it worked. After that, I just set it back to iOS 12, and everything keeps working.

If nothing worked for you, try the below steps.
Update the Xcode
Update the iOS version
Connect mac and iPhone to the same wifi

just Clean the Build Folder with: ⌘ + shift + K

Related

Xcode: Failed to prepare device for development

When I run my app in my real device (iPhone 11 Pro, OS: IOS: 15.4) in Xcode (version: 13.3), the build is succeeded, but the app does not launch in my phone and I receive this message in Xcode:
How can I resolve this ?
Well, here is a short story that I've experienced during my casual work day.
I tried to pair new phone to XCode and it prompted exactly same error as yours.
At the end of the day it turned out that phone had an Apple Watch that is paired.
We simply disabled/unpaired the phone from Apple Watch and it worked out.
Maybe you can give it a try.
Edit: Finding the XCode version that supports iOS 15.4 may also work.
In my case the problem was that I was targeting an older version of iOS than the one present in my device. Also, XCode was not updated and didn't support my phone's version. After updating XCode, I could change the iOS target to the latest and all worked out.

Xcode 12: Failed to start remote service "com.apple.debugserver" on iOS device

I updated my Xcode to Version 12.4 (12D4e) and after that I am unable to run my app on my device
iPhone X iOS 14.4.2.
Its alway show this Error
When I check my device connected status, Its show as connected
Action I applied
Clear DerivedData folder.
Unpair device and connected again.
Drank 20+ coffees.
I was able to fix the Xcode 12 app install/deployment issue described above:
Failed to start remote service "com.apple.debugserver" on device.
Domain: com.apple.dtdevicekit
Code: 811
Recovery Suggestion: Please check your connection to your device.
User Info: {
DVTRadarComponentKey = 261622;
}
...
by doing the following steps:
Quiting Xcode.
Deleting Xcode cache directory (ie, rm -rf ~/Library/Caches/com.apple.dt.Xcode).
Rebooting the offending iOS device.
Connecting the iOS device to Xcode by cable (instead of wireless network connection).
Starting Xcode again.
By the way, I've a setup very close to yours:
Xcode 12.5 (build 12E262) and
iOS 14.5.1 (on a iPhone Xʀ device)
1st solution
I fixed this by:
Closing Xcode
Deleting the current iOS version in my folder that's related to my device.
~/Library/Developer/Xcode/iOS DeviceSupport
Restarting Xcode. Wait a little bit for it to refresh and copy cache files in my case then Run.
Based on Can I delete data from the iOS DeviceSupport directory? it's ok to delete the iOS DeviceSupport folder.
I noticed when I did it and reconnected my device it re-downloaded the iOS device Support files.
If the support files don't download and the cache files are not copying, try restarting your computer as well.
I started also getting this error:
Errors were encountered while preparing your device for development.
Please check the Devices and Simulators Window.
Restart your phone and reconnect it to the compter if this happens. Then you should get a message in Xcode saying:
Preparing your phone for development.
2nd solution
Unpair the device in Xcode.
Clean the project.
Unplug and then restart iPhone.
Restart Xcode.
3rd solution
If none of the above worked, I was able to run the program by re-enabling Connect via Network.
After doing this now I can run project via USB.
4th solution
I submitted this bug to Apple. Apple also suggests this can be caused by faulty data cords. Maybe try another cord as well.
Unplug the iPhone, Turn it off and again turn it on and reconnect. It worked for me. Sometimes iPhone Debug connection network server clogs up. When you restart iPhone it reinitiate the connection.
This issue keeps happening and it seems like there's a myriad of reasons that may cause it, and so there are a lot of solutions that fixed it for people. Someone even suggested that none of the fixes actually work, and it's only the fact that time passes as we try different solutions that actually fixes it. Nevertheless, I will share what worked for me and what I found so far.
a. In the past, the issue was most often caused for me by using an older version of Xcode with a newer iOS. Apple doesn't always release the version of Xcode that supports the latest iOS at the same time, and this issue sometimes happens as a result of that. There are people who suggest right clicking the Xcode App > Show Package Contents > Developer > Platforms > iPhoneOS.platform > Device Support and renaming the folder for the latest supported version to the one running on the phone (for example renaming 16.0 to 16.1). I've had better luck with using the Beta of Xcode if it's not out yet (in this case using 14.1 RC2 instead of 14.0.1).
b. Incrementing the build number and setting a Display Name. This seems to have fixed the issue after nothing else worked. Again, this seems very random, so it could be unrelated, but it did fix it in my case after nothing else suggested on all the threads about this worked.
c. Deleting the profile in Settings > General > VPN & Device Management
Other suggestions I've seen across threads:
Restarting the device (seems to be the most popular solution)
Unpairing the device
Checking device status under Window > Devices and Simulators. There may sometimes be some further info about what is going on here, the device may still be preparing for development or downloading symbols or whatever
Using another cable. This never worked for me, after trying with 3 cables, 2 from Apple and one 3rd party, but others reported it worked
Deleting Derived Data (use Dev Cleaner or rm -rf ~/Library/Developer/Xcode/DerivedData
Uninstalling the app manually from the device
Resetting Network Settings
Force restarting the iPhone
Apple really needs better errors and less ridiculous bugs like this.
I had to update Xcode to fix this issue because my version of Xcode did not support my up-to-date iOS version.
I've had the same issue and also had the problem that I wasn't able to connect my device by cable (it popped on and of), so I had to use wifi connection on Xcode.
I was able to see the icon of the app created by Xcode on my iOS device, but whenever I tried to start it, it won't do so giving the "Untrusted Developer" error message.
I fixed this by going to:
Settings > General > VPN & Device Management > Developer App
Here you have to chose the App and consent to trusting it.
I reset the iPhone network settings and it works!
I have the same problem, my solution is update my ios version(15.1 to 15.2 beta)
I tried all the resolvent, nothing worked
restart iOS, Xcode, macOS
clear DeviceSupport, Caches
unpair iphone, change lighting cable
Then I find my ios version(15.1) does not exist in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport.
I try to fix it, but failed.
Finally, I can only update my iOS device to 15.2 beta version, It solved! Xcode is update to beta version too.
My devices original version:
iOS 15.1
Xcode 13.1 (13A1030d)
I'm on Xcode 13.3 and I fixed this by unplugging and plugging the cable between my MacBook Air and my mini iPad 3.
I fixed it by,
Following the steps : Window > Device and Simulator > Select your device and Right Click on it > Unpair after that re-connect your iOS Device then boom... Clean builds and run the app, it will work for you.
Upon solutions aren't working for me. Restart my iPhone then all well done.

Xcode - iOS Simulator window is blank

I'm running the latest version of macOS Big Sur with Xcode 12.2 beta 3. I build my app for the simulator and it succeeds - but the simulator screen is blank. The same thing happens when I go through the menus and open Simulator manually - Xcode > Open Developer Tool > Simulator. I have tried adding a new simulator device, and running xcode-select --install.
Preferably, I would rather not have to re-install Xcode as I have limited space and would have to juggle other applications, use an external hard drive etc (I have a 128GB MacBook Air).
This is what appears when I try both methods.
I determined the problem.
There was a bug in the developer beta version I was using.
It was causing the simulator to fail to launch correctly.
I have reported this bug to Apple through Feedback Assistant, and moved to a stable version of Xcode which is now working with the simulator.
I agonised over this for ages since I moved to the MacPro M1.
App run fine on connected fysical IOS device but not in emulator...
Upgrading MacOs and Xcode fixed nothing...
Was finally on MacOS 12.3.1 and Xcode13.3.1 when I figured it out.
The only thing that finally actually worked was removing the check to run Xcode with Rosetta and to be sure downloading a new IOSXXX simulator.
Go to Applications -> right click on Xcode --> Get info --> uncheck Open using Rosetta.
Hope it helps for you!

dyld_shared_cache_extract_dylibs failed for iPhone XS Max running ios 12.1.2

I am trying to run my app on iPhone XS Max running iOS 12.1.2, but till the end of the build and it returns "dyld_shared_cache_extract_dylibs failed" , i removed the supported files for it and rerun my app and it gives the same error , any suggestions i'm stuck ?????
There is a (temporary) solution I've been using...
Open Devices and Simulators
Remove your device from the list
Tap the + button on the bottom left of the window
Select the device (before tapping Trust on it)
Tap Trust on the device
Profit
For me I still have to do this steps every time I connect the device...
I have both Xcode10.3 and Xcode11.2.1 installed on same machine. Whatever solution I try, it doesn't work with Xcode10.3 and iPhone11. It works like a charm on the latest Xcode though. I think the solution is to switch to the latest Xcode version.
I recently solved this issue by installing Xcode 11.2 and 10.1 alongside each other, and using Xcode 11.2 to build the debugger files. It seems 10.1 can't handle newer versions of iOS and builds the debugger support files incorrectly.
Delete everything under ~/Library/Developer/Xcode/iOS DeviceSupport/ related to the version of iOS giving you trouble. This is where Xcode saves the debugger support files. Then launch Xcode 11.2 with the phone connected and allow it to build the debugger support. After it has finished, close it and open Xcode 10.1 and it should work.
i tried everything and my solution was go to app store and download again xcode, he is going to updated by self
try Run it in latest Xcode version then try again in the version you want
and try to reboot the mobile device and unpair it and connect it again thats worked for me
BTW thanks #unstablerealtiy

Unable to profile app on device with iOS 9.0.1 using Xcode 7, 7.0.1 or 7.1 beta

I have been trying unsuccessfully to profile my device (via Instruments) using the latest version of Xcode 7.0.1 (7A1001 released 9/28), as well as the previous version of Xcode 7 (7A218), as well as Xcode 7.1 Beta 2 (7B75).
My device is an iPhone 6+ with iOS 9.0.1 installed - the latest GM release of iOS9. I am able to run / debug applications on this device without issues.
In the screenshots below you can see that my device is disabled (greyed out) in all screenshots in all versions. I am able to profile other devices running iOS 8.4.1 without any issues.
Does the current version of Xcode not support profiling against iOS 9.0.1 or is there some kind of configuration setting or known work around for this?
Xcode 7.0.1:
Xcode 7.0:
Xcode 7.1 beta 2:
TL;DR - Perform a complete reboot of your device; restart Xcode & instruments; select "Open Xcode" if prompted to enable the device for development.
Update 3/31/2016: I haven't encountered any issues with the latest version(s) of Xcode (7.2.x, 7.3), so it seems that the stability here has been improved.
I believe I may have finally gotten this to work properly. Detailed steps:
Unplug the device from your Mac & power down the device completely (hold the power button for several seconds; slide to power off).
Close Xcode and Instruments.
Restart the device & once it has booted completely re-connect it to your Mac.
Re-launch Xcode. Here, my device showed as disabled and Xcode indicated that the device was not available for use.
Open your project; clean (Shift+Command+K), Build (Command+B), Profile (Command+I).
After Instruments launched I noticed that the device was enabled. Upon selecting it, a message was displayed with the title "Enable this device for development?" and message "This will open Xcode and enable this device for development." (Note that this only happened to me the first time I went through this process even though I had already been using the device for development - whereas some users have also reported that they are not presented with this dialogue.)
Click "Open Xcode". Here Xcode did not prompt me for anything nor was anything displayed - no additional messages indicating anything had been done or that the device was or was not available for development. Opening the Devices window, the device appeared to be available. (I have not been presented with this option for subsequent occurrences.)
Now I was able to select the device in Instruments and profile it.
As a side note, I was also again able to delete installed apps from the Devices window (I realized that this was not possible to do previously).
I'm unsure how my device ended up in this state however I will be on the lookout to see if this continues to occur.
Please note that this was done using Xcode 7.0.1.
Update: My device seems to lapse back into not being able to be used for profiling some time after performing these steps - I've had to reboot my device again in order for it to be available for profiling. Not sure what is triggering this behavior but I will file a Radar for this.
Close instruments -> reset your device by long pressing home and power button -> restart instruments. Works for Xcode 7.3.
According to Apple staff on the developer forums the behaviour of this issue is greatly improved in the Xcode 7.3 betas, so one easy solution is to try upgrading Xcode. I've upgraded and it seems to be behaving so far.
This issue still occurred with XCode 10.3 and iOS 12.4.2
I restarted the device only, and it worked.

Resources