Xcode 12.3 keeps freezing - xcode

I updated to the latest AppStore release of Xcode (12.3, 12C33).
It worked fine for an hour or two. After that it started to constantly freeze after being open for a few seconds to minutes.
I've tried the following, all without success so far:
restart macOS
clear derived data
tried with different projects
updating to latest macOS 11
Any other ideas or suggestions how to fix this?
Update
I can confirm that this is fixed in Xcode 12.5

I found an answer by Darr on the question "Xcode freezes after upgrade to 12.3" on Apple's developer forums that worked for me:
Unpairing my device connected via network and using only lightning cable seems to have resolved the issue for me.
Xcode > Window > Devices and Simulators > device > Connect via network

After going mad, I fixed this by removing all devices from Devices and Simulators (I had connect via network activated).
For now, it's working fine.

Power off your Apple Watch
Xcode may hang if the host Mac is connected to an iOS device which has one or more companion watches. The hangs occur when the watches aren't fully prepared for development, or if they are experiencing poor wireless connectivity. (72490921) (FB8945320)
Workaround: Power off the watches, or unpair them from the iPhone.
Xcode 12.4 Release Notes
You can force Xcode to freshly prepare a watch for development using these steps:
Force-quit Xcode.
Power-off and disconnect all iOS device from the Mac.
Reboot the Mac.
Launch Xcode, close all projects, and open the Devices and Simulators window.
Power-on and unlock an iOS device and its companion watchOS devices by entering the passcode as required.
Plug the iOS device into the Mac using USB cable.
Check each iOS device and each watch for any pairing request and approve the requests.
Monitor the status of device preparation in the Devices and Simulators window. If Xcode presents device-preparation errors, follow the guidance in the error message to resolve the error.
Once Xcode finishes preparing the iOS device and its companion watches for development, repeat steps 5 through 8 for each remaining iOS device and its companion watches until you verify that Xcode has prepared all devices for development. You may now open your Xcode projects and resume development.

I've been having the same problem. I had an iOS device connected via USB, unplugged it and it un-froze. Then I continued to have issue requiring force close each time.
I then clear derived data and things have been fine. I opened a StickerPack project and also had the same issue. Clearing DerivedData also fixed it.
Clear Derived Data:
Xcode pulldown menu > Preferences > Locations tab
Click the little arrow next to the path under Derived Data.
Delete the entire folder for you project. It will look like "MyAppName-bwonddotztrgkkfexrjxoncvmjit"
See this explanation about whether it's safe to delete DerivedData for your project.

I had the same problem with appstore version and someone advised to install from site, now it works fine. https://developer.apple.com/download/more/

Disable WLAN on my iMac fixes the problem currently.
Hope they will releast a fix very soon.

Xcode 12.3 is unstable and many times it crashes.
I reverted back to Xcode 12 and copied disk image of 14.3 in Device Support folder of Xcode (Contents > Developer > Platforms > iPhoneOS.platforms-DeviceSupport).
This I needed to debug on iPhone device having version iOS 14.3
https://github.com/mspvirajpatel/Xcode_Developer_Disk_Images/releases

I recently had similar situation. My Xcode 12.3 project could not be opened. I tried to open directly from popup that appears on start of the Xcode.
What worked for my was to downgrade Xcode to 12.2 and launch Xcode on new project. And then click my old one.
Maybe it would work without downgrading but I didn't check.

I had this problem too. I fixed it by going Devices and Simulators in the Windows file and disconnecting the iPhone reference I had for my phone when testing and app. Since the phone was no longer connected, its presence seemed to create a freeze.

In my case XCode 12.5 hangs/freezes on startup more or less instantly, right after it opens kind of an empty workspace.
I removed everything that I could imagine that deals with XCode on my machine, but it didn't help.
At the end I just used the hotkey for "Close Workspace" - Ctrl+Alt+Cmd+W
I hit this combo very often, very fast right after opening XCode and it worked!
The strange empty workspace showed up and closed instantly - now I could select other projects and everything works again.

There could be the multiple reasons and in my case reason was source control
preferences > Source Control > uncheck Enable source control

I have these performance problems with the newly updated Xcode from the AppStore to 12C33 (Xcode frozen for many seconds, instability of interface builder, etc.) only with apps which have frameworks added with cocoa pods and when working in the xcworkspace-file. (Integration of frameworks with Catharge even fail with error message 65). I'm running Xcode under macOS Catalina. Don't know what the technical reason could be, hence would appreciate if someone has an idea on this how to fix it.
Update: In the meantime I could fix it:
I eliminated my own devices from the device list and did then a deintegration and a new install of the cocoa pods for the projects. Afterwards I setup my devices again in the device list and all worked well again. Only eliminating and reintegration of my devices as described above didn't work in my case.

Related

Location Simulation not working in Xcode 10 and iOS 12

I am developing an app that uses GPS. In the simulator I always used the location simulation feature of Xcode which always worked for me.
I selected the Debug - Location - Freeway Drive option in Xcode 10.
Whenever I select some preset to simulate, Xcode shows the following error:
[Client] #Spi, Interrupted
GPS is enabled on the simulated device and the app has permission to access the GPS. I already tried to restart the simulator multiple times, selected another device, but no device works. Does anyone have a solution to this?
Regards
Xcode 10 is broken with respect to Location Services in my experience. I've had to go back to 9.4 to develop and debug apps, but even then I have had problems with running apps originally modified with Xcode 10 running in iOS 12.
Apple is having serious, SERIOUS quality control issues and legacy issues with each new release of Xcode and iOS. I'm very frustrated and annoyed.
I was having this issue and reseting the simulators seems to have fixed it for now:
$ xcrun simctl erase all
Simply click City Bicycle Run and then City Run in Debug -> Location in the Simulator over and over again until it works. At least it worked for me that way
I'm suffering the same issue with Xcode 10.1 and iOS 12. Several restarts of the App and toggling between different locations (None, Apple, City Bicycle Ride) make it work again.
Quite annoying
This worked intermittently as a workaround for me:
On the simulator debug menu, select location and freeway drive (or whatever you want) several times until it starts to track the location.
It also helps to build the app on the simulator again
Good luck!
Looks like the location simulator has not been fixed in Xcode 10.1 update.
In the simulator, go into device settings / Privacy / Location Services. Toggle Location Services off and then back on.

Xcode No Devices Registered Error

My macbook registered to my apple account which is I'm using on Xcode. Im taking 'no devices registered' warning. How can i fix it ?
Plug in your own device to your mac, then on Xcode change the simulator to the device you just plugged in, the issue shall be gone.
Change the simulator back to whatever you want if you don't want to work with your own device.
Select Organiser from XCode. Now under Devices, select your device. If it is not ready for development then click use for development.
If above doesn't solve your problem then from your project settings, set deployment target to one which your app is developed for or lesser.
Otherwise there is some issue with certificates and provisioning profiles. Make sure your device's UDID is added in the provisioning profile you are using.
This is a bug even in Xcode 9 beta. May be not a bug. When you are trying to get back to a previous version, e.g. the GA version, you might not see any simulators.
For me it was caused by updating the iOS develoyment target to version 11. Once I switched back the target to 10.3 the simulator devices reappeared.
Also the beta might have edited the “Swift Language Version” (SWIFT_VERSION). It is also required to be configured correctly. Back from version 4.0.

Xcode Project won't run on iOS Device

Xcode gives me this message every-time I try running my app on my iPhone. (Works fine on the simulator.) (And this occurs in every project I have.) (I also just downloaded Xcode again.)
This is the message I get.
App Installation Failed.
Unknown Error Occurred.
How do I fix this error?
Unplugging iOS Device and plugging it back it in fixed it for me.
Alright, it was a simple fix:
Go into Xcode Preferences -> Accounts -> More Info. Hit the refresh icon.
Clean your project. Project -> Clean.
Force quit Xcode.
Reboot Mac and Device.
If you have the same App but downloaded from AppStore, I suggest to remove the App manually from your device, then try to run the new version with XCode.
After following the suggestions in this thread (restarting iPhone, cleaning Xcode project, quitting and re-launching Xcode) and others (setting Team to None then back to my Team) and unplugging and replugging Lightning connector from my iPhone 6 I was still experiencing this problem. Xcode would even display an error that my iPhone 6 was locked, even though it was not.
I was able to fix it by unplugging the USB-A connector of the USB to Lightning cable from my MacBook Pro, then plugging it back in. I'm not sure why that made the difference, but glad that it did resolve this annoying problem.
I have this issue regularly. There are a number of techniques that help me overcome it, including the classic "turn it off and back on again."
One thing that isn't mentioned here is that the iPhone should be switched on, unlocked, connected to the mac and then the app should be run (with the iPhone unlocked). Don't lock it!
Make sure your device name doesn't have any emoji (Xcode 11.0)
if you using vpn services, then you need to turn off vpn. Works for me

Safari Web inspector keeps disconnecting

I've Safari 8.0.6 with iOS 8.3 on my iPad, while debugging through Web Inspector on my Mac (10.10.3), the connection keeps on disconnecting (I don't see the device name under Develop menu upon disconnection) but can resume if I quit safari followed by a relaunch then I'm able to refresh and inspect remotely again.
There are a few things to try:
1. Test on the Xcode Simulator:
Open the iPhone simulator in Xcode and debug there with Safari Web Inspector.
Sidenote: Maybe you need to download the Safari Technology Preview
2. Reset your location and privacy settings on your device.
Settings > General > Reset > Reset Location & Privacy
3. Debugging on a real device
With this configuration it seems to work right now.
iPhone X, iOS Version 12.1.3
macOS Mojave Version 10.14.2 (18C54)
Safari Version 12.0.2 (14606.3.4)
Edit 2019.08.13
Settings -> Safari -> Advanced -> Check that Webinformation is toggled on.
It was suddenly toggled off and I couldn't connect via the Web Inspector. After toggling it on, it worked.
For other devices / versions, please read further down (Maybe you can decrease your build size).
EDIT: 2018.09.20
#Chet found out, the Web Inspector keeps disconnecting for too large JS files and map files
https://stackoverflow.com/a/52338231/4641479
Issue on Github:
https://github.com/google/ios-webkit-debug-proxy/issues/275
https://github.com/google/ios-webkit-debug-proxy/issues/274
I could confirm this on a real device with a production build (1.8 MB + 2.4 MB files), the Safari Web Inspector stays always connected.
Since for the development build it is not:
Before my web inspector very rarely worked and often just stopped working - but was still open. After the safari update the web inspector opens and closes immediately. If you encounter such problems..
This will work:
Step 1. Get the latest Safari Browser
Safari: 11.1 (12605.1.33.1.2)
https://developer.apple.com/safari/download
macOS Sierra and OS X El Capitan (I assume macOS high Sierra is also supported)
Maybe you need to download the Safari Technology Preview
Step 2. Reset your location and privacy settings
On your device go to:
Settings > General > Reset > Reset Location & Privacy
Source: https://forums.developer.apple.com/thread/87181
Step 3. Connect your device
Open Safari on OS X
If you had connected your iPhone device with an usb cable, disconnect it first.
Now plug it in.
On OS X Safari go to:
Develop > Device name > Apply for development
Now on your phone there is a permission question. Choose trust and now you can choose the open tab on your devices safari and debug.
Happy debug!
Now the web inspector stays connected.
Do you have a lot of backgrounded apps running on your iPhone? Kill them and try again.
We showed this issue to Apple developers at WWDC, and they suspected it was due to memory constraints on the iPhone. Sure enough, killing most of our backgrounded apps resolved the issue for us.
Working Solution (as of 24th Mar 2020)
Well, after so many trials and opening thousands of blog posts to figure out a solution, I managed to get it working without a single case of failure.
For me, this has been always a problem with my Ionic+Cordova application.
My subconscious mind started to think about this problem when I saw that this issue (of Safari getting disconnected) is not there when I run a plain simple Cordova or Ionic application. And then suddenly, I tried another thing and it worked.
Basically, the Safari web inspector disconnects when the size of any files are too large (not sure about the limit). Maybe, some image, some script, and CSS. In my case, it used to because of the JavaScript & their source map files.
So, when I started to run my iOS application without source maps, the problem is gone. For that, all I had to do is to pass --source-map=false to my ionic cordova commands like:
ionic cordova run ios --source-map=false
ionic cordova run ios -lc --source-map=false
I wrote a small article about this to elaborate this in detail https://medium.com/wizpanda/a-small-tip-to-speed-up-development-with-angular-or-ionic-d5764f639c0c
Original Answer
Most of the answers listed here worked for me for a while but after a few hours they also stopped working and my Safari web console again keeps disconnecting as it opens.
Other few options that worked for me:
Option 1 - Empty Cache From Safari
Safari on MacOS -> Develop -> Empty Cache
Option 2 - Clear Trusted Computers
On iOS Device -> Settings -> Developer -> Clear Trusted Computers then reconnect the USB cable and then try to debug again
Option 3 - Make the debugger fool (as of 14th Jan 2019)
This solution is working for a long time now. Since this is an issue related to connection between iOS & Mac so I opened my Console app and just kept my iPhone selected. (This is somehow kept my iOS device connected to my Mac)
Then opening the Developer's console on Safari worked fine for me without disconnecting.
Option 4 - Run via Xcode
This is also a kind of workaround and a hack to see it functional. You can basically prepare your iOS app by ionic cordova prepare ios and then run the app using Xcode and deploy it to your iPhone.
At least, I'm able to see the console logs and sometimes, it even works with Safari web inspector.
Option 5 - Run on iPhone simulators
I think this is the most working solution. This option is suitable when your system is not running too many applications as firing a simulator suckup a good amount of system resources.
Basically, instead of running your app on a real device, run your app in an iPhone simulator via Xcode and debug it normally in your Safari web inspector and this problem will not occur.
This is probably because the files being transferred to Safari inspector is from the system itself.
Sounds strange but it may be happening due to the battery being full triggering a disconnect: https://forums.developer.apple.com/thread/92290
The disconnection seems to occur when the battery of the Iphone is full. (So for the moment we turn the flash and the camera on to kill the battery while inspecting ...)
This is only necessary for physical devices. Physical devices can be forcefully disconnected by Safari if the device's battery is full. ("Full battery? Well then, let's just disconnect you as you don't need to charge anymore -- and there goes your debugging session too...")
You will want to select Connect via Network in Develop > [device], and then attach your debugger to the page you want to debug. If you do not have the Develop menu in Safari, go to Safari > Preferences > Advanced and select Show Develop menu in menu bar.
If this doesn't work, you may try upgrading your OS/Safari through the App Store first.
If things are still breaking, disconnect your iOS device. Go into your iOS device into Settings > Safari > Web Inspector and turn it off and then back on. Force quit out of Safari. Re-plug in your iOS device and start up Safari again and re-attach your iOS device through Safari > Develop menu.
Closing XCode first helped for me.
This plagued me for a long time with very inconsistent behaviour, here are a few things I have found that help, I also wrote a blog post on this here.
Update both mac safari and ios - I have found after having the latest of both versions it started working for me, there could be debugging incompatibilities between Safari's.
Check that web inspector in ios is enabled - It has been known that this setting can be switched off after an upgrade, check in settings > safari > advanced > web inspector.
Check the port you are connected to - I have had mine plugged into a cheap hub / via apple keyboard/monitor hub and found that going directly into the mac works much better.
Are you using a good quality cable? - I have found that better quality / official cables that aren't worn out have better reliability when in debug.
Other notable observations - other people have commented that making sure cookies are enabled in safari, enabling private mode and trying whilst Xcode is open have affected the reliability of this, although I haven't seen this myself it may help others to try.
I can't say I have a solution, but a step in the right direction.
I tried using ios-webkit-debug-proxy so I can use the Chrome Dev Tools instead of Safari Dev Tools.
Note, in order to get it to work, I can to upgrade my iOS to the latest 11.4.1 and MacOS 10.13.65, then reinstall the latest versions:
brew update
brew install ios-webkit-debug-proxy
brew reinstall --HEAD libimobiledevice
brew reinstall -s ios-webkit-debug-proxy
ios_webkit_debug_proxy
After running ios_webkit_debug_proxy, I was able to try to connect through chrome://inspect and it disconnected immediately again:
Listing devices on :9221
Connected :9222 to Chet's Phone (6a028994cf281be807bf80c5557c3f2eb3fbb8b0)
Invalid packet header 0x1ffffff91ffffffa0ffffff9d == .... == 26321053
Disconnected :9222 from Chet's Phone (6a028994cf281be807bf80c5557c3f2eb3fbb8b0)
However, we have a clue! Invalid packet header. Sounds like a lower level bug somewhere. Not sure where to submit this but to though...
The magic solution worked for me:
Reboot your MAC
Reboot your iPhone
09-07-2020
Still this issue on Latest MacOs (Catalina 10.15.5) on Safari (13.1.1)
Solution on Ionic/Capacitor:
ionic cap run ios -l --external --source-map=false
The most recent Safari Technology preview appears to have solved it for me.
https://developer.apple.com/safari/technology-preview/
MacOS Mojave / Catalina Solution
For me the issue started right after I upgraded to the new macOS Mojave, this might have been mentioned somewhere above but for me I just needed to download the new "Safari Technology Preview" app that is built for Mojave.
Safari Download Page
https://developer.apple.com/safari/download/
Direct Download for Mojave
https://secure-appldnld.apple.com/STP/041-71285-20190604-6d0dcb17-07e5-40a0-b418-dba732cefe64/SafariTechnologyPreview.dmg
For me using a different adapter and cable solved the problem.
Every time you connect, it should ask for "Trust this device" like prompt on smartphone, if not then it's the cable/adapter issue.
When using a content-blocker (e.g. 1Blocker) on your iOS device, make sure it is disabled for the domain you want to debug.
Disabling 1Blocker stopped the Web Inspector (Mac) from closing immediately after opening it, and allowed me to get back to work.
I know there's a lot of answers already, but I wanted to post because none of them worked for me just now. But, my phone's battery was in "low mode" ... but since I'm plugging it up for development, I didn't think that was a big deal. But, going into settings on my phone and turning off low battery mode fixed my problem. Now safari doesn't disconnect.
Just wanted to post that in case someone runs into this with a low battery.
Working solution for ionic app:
ionic cordova build ios --source-map=false
Capacitor, Ionic, Cordova
rm -rf platforms/ios/**/*.map
I've been seeing this issue when using live preview in Capacitor while building an Ionic Angular project on macOS Monterey previewing on iPhone Xs. Here are a few ways I can get over this bug and continue development...
Make sure you're using Safari Technology Preview and not the regular version of Safari.
Close and Re-Open Safari Technology Preview if it continues. You could also try inspecting using regular version of Safari after installing Safari Technology Preview. It may work for debugging almost as well.
On your device, open the app switcher and close all background applications before starting development on your app.
Toggle 'Connect via Network' in Safari on your computer by using: Develop > Device Name > Connect via Network in the Safari menu.
Disconnect and reconnect the lightning cable of your device. Make sure it has a steady firm connection to the computer. Off-brand cables can cause intermittent development issues.
Quit your app, go to the app switcher and force close your application by swiping it away. Then re-open it using the app icon in the launcher. Try inspecting it again.
Try rebooting your computer and rendering your app again. After a lot of up-time there may be some built-up log data that needs to be dumped.

Xcode not detecting my device

I upgraded my iPad device OS version recently to 5.1.1 (9B206). From that my Xcode is not detecting my device. Am just getting iOS Device and simulator options in my Xcode. But am getting my device in older version of Xcode and iTunes. For this i updated my MAC OS version to 10.7.4 and Xcode version to 4.3.3. But still am facing the same problem. Now how to make my Xcode to detect my device?
This Worked for me.
Quit Xcode.
Disconnect the device.
In a terminal window, type: sudo pkill usbmuxd (it will be restarted
again automatically)
Restart Xcode
Connect the device
Your device should now be visible again in Xcode!
Open the Organizer in Xcode, go to devices, find your device and click the option to use for development
I just plugged into another USB port and it detected by device.
In another case, check the "iOS Deployment Target" in "Build Settings",
if the target iOS version number is great than the version of device,
then the device will not show in the list.
Say that, the "iOS Deployment Target" == 7.0, and the version of device is 6.0,
to solve the problem by change the "iOS Deployment Target" to 6.0 or lower.
If the chosen answer still does not work for you try this:
Select the project in project explorer
Select the target on the main window
Select Build Settings
Select Deployment
Select iOS Deployment Target. Change it to the version of your device. (e.g. iOS 5.1)
I was also faced the same issue in Xcode, my device was not detected after update the Xcode latest version(7.3.1)
Done so many things what suggested in the web-search but still the device was not detected.
Finally, I just quit and open the Xcode my device was detected(oh my bad).
This SO answer solved it for me https://stackoverflow.com/a/56054170/5813473 .
sudo killall -STOP -c usbd
did the magic.
Well later I had to unplug/plug in again at occasions, but that 'killall' really solved the original issue.
Most recently, Xcode 8.3 and iOS 10.3 seems to have more security around Xcode accessing the iPad/iPhone. My sequence:
Rebooted the machine,
Attached the iPad,
Gone through a "trust this computer" security cycle on both iMac and iPad
Xcode can now see the device
Sometimes restarting Xcode helps. Give it a shot.
In my case, restarting Mac worked and no other solution.
I updated my iPad (it's in Settings -> General -> Software Update, near the top) and restarted my computer and Xcode sees it now.
FWIW I tried all the tips in this thread and nothing would work: from reboots, command line statements, unplugging, different USBC ports, etc. I also tried something not mentioned here (yet) by going to "Settings > General > Reset > Reset Location & Privacy" ... however even this didn't work.
Later on in the evening I was in a different room of the house and out of nowhere I got the "Trust This Computer" prompt on my iPad. I of course tapped "Trust" or whatever and then magically my Mac laptop finally sees my iPad.
I realize I'm not really giving a helpful tip/fix here - just sharing how things went for me in case anyone finds useful.
iPad: iOS 13.4.1 | Macbook laptop: OSX 12.3.1
Recently (2022) I've noticed that the iPad prompt to "Trust this Computer" won't appear unless using an Apple USB-C cable. Apple reps assure me they aren't doing any funny business here, but I have tried every cable I can find, including several thunderbolt 3 and 4 cables and Anker cables. Worth trying an Apple cable if still having problems.
Just simple, close the project on your XCode. Just right-click on the XCode in the taskbar and give a quit option. After open the XCode from the directory, it will detect your device. It also work on Xcode version 11.2.1
close your project or XCode.
Give Right click on the Xcode in MAC tabbar and give the Quit option.
Reopen the project from your finder(project place).
The device will be automatically detected.
Open the Windows in Xcode, go to devices. If Device is visible in Left side, Right click and select "Show in Destination Menu".
Enjoy..

Resources