XCode 6 GM: Constantly freezing / locking while editing Swift code - xcode

Since installing XCode 6 GM, it has been freezing and locking, showing the spinning wheel of death while I attempt to edit code that has syntax errors. Has anyone else seen this, and are there any known work-arounds?
I foolishly abandoned my cautious strategy of saving the previous version (Beta 7) and it appears that Beta 7 is no longer available for download. Are there any known archives of / for the link?
I have also posted to the dev forums and will follow up with a bug report, but it is hard to pin down the exact circumstances.
Edit:
Additonal Notes:
CPU: SourceKit Service is generally around 100%, but that has seem to have been the norm for the flavors of XCode, and the CPU seems to properly drop off when it finishes recompiling.
RAM: SourceKit is no longer exhibiting the memory leaks that used to cause it to halt and catch fire, memory does not appear to be a factor, and there are several ~ 5+ gigs to spare.
Environment:
Late 2012 Mac Mini, 16GB RAM
OS X 10.9.4 (to be fair, this was new today as well, driven by the requirements of XCode 6 GM).
That said, only the software changed today.
Update
Apple claims that this bug is fixed in Beta 6.1, for what it's worth.

You should look if you have any imports missing in your bridging header file. Sometimes even commented out imports will cause this behaviour. For me it was commented out Pixate Freestyle Cocoa Pod. I had to remove pod completely from my project to stop SourceKitService from crashing.
https://stackoverflow.com/a/25173389/527539

I can't say any of these fixed the issue, but they alleviated the situation:
I removed all playgrounds from the project tree. Saved them somewhere else.
I removed all objectiveC code from the swift project (when possible). This Spinning-wheel, BTW, is a problem only in my swift projects. My other Objective-C-only projects are fine.
It looks like it's the background indexing process which is taking all the CPU. Open "Activity Monitor" and see it right there at the top, using 360% CPU. Lowering the priority for this process helped as well (type in terminal):
renice 10 -p [pid]
Make sure to take the correct process id from Activity Monitor.
The higher the number (should not exceed 19) the lower the priority.
I make significant changes one at a time. It seems that the amount of errors in the file affect how many times and for how long the spinning wheel spins. It looks like some type of errors trigger it more often than others, but I'm not able to pin point which exactly.
XCode had a similar indexing issue in previous versions (see this Xcode4 issue: How to disable indexing in Xcode 4?) which gives me the hope they will fix this issue sometime, hopefully soon...

I create a new tab via menu File->New Tab and close the old tab that is frozen.
CmdT does not work that time.

Related

High CPU load of diagnosticd process while running React Native app on iOS simulator

I have been developing with React Native for some years now but the following behaviour only started recently. After running any React Native app on the iOS simulator (either directly from Xcode or via react-native run-ios) the diagnosticd process slowly increases CPU usage to 150% after a couple of minutes. My laptop becomes unusable because the process is also eating up all file handles of the OS. Googling around only points to excessive logging, but either I'm not looking in the right location or no huge amounts of logging is taking place.
Closing the app by pressing the Home button in the simulator immediately stops the high cpu load.
Is anybody also experiencing this? How can I find out what is causing this?
MacOS Catalina version 10.15.3, Xcode version 11.4, React version 16.9.0, React Native version 0.61.5, Simulator iPhone 11 (iOS 13.4)
I think I found the solution. Xcode was logging a lot of lines containing: xcode nw_connection_get_connected_socket Client called nw_connection_get_connected_socket on unconnected nw_connection. This started after some update of Xcode a couple of months ago. Disabling the logging has stopped the diagnosticd process from eating up all OS resources. I followed these instructions: Hide strange unwanted Xcode logs
Basically comes down to adding an environment variable OS_ACTIVITY_MODE with value disable to the Scheme (Run).
What the real reason for the logging is I still don't know. It looks like some sort of polling from React Native.
It's more of a workaround than a solution, but it seems that resetting the simulator to factory default temporary fix this problem (at least on my case).
It looks like diagnosticd is processing some files which may be located on the simulator internal memory, so it may takes more and more cpu as the files are growing over time ?
Anyway try to go to the simulator menu : Hardware -> Erase All Content and Settings
Then close the simulator and start it again from XCode in order to copy your app on it.
workaround from Xcode 9.3 Playground - diagnosticd,
kill $(ps -ef | grep Xcode.app | egrep "diagnosticd|homed" | awk '{ print $2 }')
I found this to be useful
Finally found the solution! I was always wondering why the default url in AppDelegate.m did not work. So I started focusing on that. It turns out that my huge adblocking hosts file was the cause of this. Restoring the original /etc/hosts file solved both problems! 🎉
One more thing you can try, this is a very drastic measure and only do this at your own risk,
first try this,
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.diagnosticd.plist
and if you get a message about system protection (SIP),
you can try turning off SIP, then running that command again,
That will pretty much guarantee diagnosticd never run's again... no idea about the implications of that though...
read more about those two things here,
https://makandracards.com/dev/16439-disable-daemons-services-in-mac-os-x
https://www.imore.com/how-turn-system-integrity-protection-macos
*disclaimer, this is probably not the safest solution messing with SIP, but I did it on my old 2015 i5 macbook because I was getting desperate, and literally couldn't do any work on simulator with the diagnosticd bug.
So far everything seems happy...

Xcode never finishes building and uses up memory on computer

I’m trying to build my Swift app and, as the title states, it never finishes building and eventually I get a warning for critically low system memory. I have about 23GB free on my computer but as soon as I hit build and watch the memory usage on Activity Monitor the Swift process gradually increases in size, reaching tens of gigabytes in size until my computer dies. This only recently started happening but I don’t know how to solve it. It also seems to happen whilst Xcode indexes my project. It gets stuck at the "Compiling Swift sources" stage. Does anyone have a solution?
I solved it! The problem was I had a function that was a bit complex and it was returning a value, but I had set the function as void. I tracked this down by removing files that I'd recently changed from the target and then compiling to see if it would give an error or just compile forever. Then I commented out bits of code.
I solve it by cleaning the code first (shift+command+K)...
Then keep it free for indexing...
After that rebuild (command+B)...
And it works fine...

What does com.apple.CoreSimulator.CoreSimulatorService do?

Our iOS automation tests on simulator have gone through disaster since upgrading to Xcode6.
We can observe view switching slowing down, UIAutomation felt it too and often returned an empty or not fully updated app main window, you can imagine the stability.
Part of the reason is that we have slow VMs, but still we need to find ways to workaround it.
Then I notice there's the CoreSimulatorService process staying alive between the launches and shutdowns of simulator. So I killed it to see what change would it make:
killall -9 com.apple.CoreSimulator.CoreSimulatorService
After it was killed and relaunched, the performance of simulator seem to get much better, at least I don't see random fails anymore (hopefully). I guess this is kind of cleaning up.
So I hope to get a better idea about what function does CoreSimulatorService perform exactly?
Also, I am confused about where to find the documents when Apple releases new things (forgive my ignorance). For example, I didn't find any documents in iOS developer library mentioning simctl except Xcode Release Note.
Thanks!
I just faced a unexpected CPU spike due to this process (Xcode 12 & macOS 12).
A quick look on the web showed that most of the time your look for com.apple.CoreSimulator.CoreSimulatorService you will find people afraid of "something" and that are resetting everything. Ultimately this will "resolve" (as a workaround) the problem that isn't really one.
I opened ActivityMonitor (and not just looking at iStat Menu CPU widget), I found that the process update_dyld_sim_shared_cache was responsible for this CPU high usage.
Just reading the name show that the process is probably doing something expected after all (I got this issue after an OS update).
I just waited a around half a hour and the CPU went back to normal.

Xcode runs slowly and hogs CPU

Lots of times Xcode (seemingly randomly) starts to run extremely slowly- it can take around fifteen seconds to move an object in IB, or compiling after changing one line of code can still take up to ten seconds. I took a look at my Activity Monitor, and this is what I found:
My question is, is this normal?
2GB of RAM is way more than enough, even for latest versions of Xcode.
Looks like you've hit one of the bugs in Xcode compilation / indexing / syntax hilighting. c.f.: Xcode 4.3.2 and 100% CPU constantly in the idle time
You only have 2GB's of RAM. With each update to Apple's software, they get more memory intensive. The same goes with Safari 5.1+. So to answer your question, Yes, this is normal for a machine with 2GB's of RAM running Lion as well as other memory intensive applications, Chrome being another.
As for Interface Builder, I have noticed this too. XIB's are XML files, so I believe as you move an object, Interface Builder is writing it's location on the view as it is moved, so that is a very data heavy task as well.
XCode is usually around 20-30% CPU sitting in the background doing nothing. It's a pig that's all.

why is vs2010 so slow lately? Its nearly unusable

Not sure what has happened on my dev machine but I can barely use visual studio 2010 these days. I have a copy of professional edition installed on a win7 pro x64 build running on top of a i5 M430 and 6 gigs of ram.
With only VS2010 open i've seen the process leak away to 600,000k+.
The editor is extremely slow. Every character I type sends the gui into "Not Responding" for 5 seconds and starting/stopping the debugger is a ~30 second operation.
I've done a repair install. No change.
I've removed productivity power tools and installed the perfwatson extension.
When I installed perfwatson the GUI sped up a bit while opening/loading a project. But the text editor still has an awful delay.
What else can I do? Harware rendering is off in my environment options.
an example of the slowness (literally): typing Height="1024" takes about 30 seconds to display in the text editor and do its update flash to go out of not responding. The word "Height=" takes 5 seconds to show. The intellesense and blank " " takes another 5 seconds. Each digit pops in every five seconds after that.
Needless to say even trying to edit existing work is a frustrating experience.
edit: rolled back one version on video driver. No noticeable changes after reboot.
edit: did some winforms projects today. No slow issues with this project type. Must be something with just wpf/sl projects.
edit 8/18/11: Took troublesome project to the production server. VS2010 editor works great there. Very snappy and responsive. Not at all slow. So it's not something inside my project. It's something in my machine. But a full out OS rebuild is something I can't just do now. Probably will start a bounty soon.
Delete the .sdf and .sou that have the same base file name as your solution file.
If your solution file is
c:\MyProject\project.sln
You should delete
c:\MyProject\project.sdf
c:\MyProject\project.sou
This solves 98% of the problems of slow VS.
These files contain intermediate information that is not important for the functionality of the solution and as time goes by they swell up and become bloated and fragmented. VS relies on these files for and if dealing with them is slow, everything is slow.
I know this is an old post but I have just had an issue where my visual studio project has been working fine for about 2 1/2 years and suddenly every time I clicked run I had to wait about 3 minutes and the same when clicking stop. I tried the old windows reboot but to no avail.
I found a post about deleting the projects .suo file (it was only 4MB).
I deleted the .suo file and everything is completely back to normal. I guess the file had corrupted or something.
Having a large number of breakpoints or a large number of files open can cause serious performance problems, but it sounds like your problems are worse than that...
A bios update and a intel chipset update on my machine solved nearly all my performance issues.
The slowness started to creep out into the OS and I was pegging the cpu at idle. I've got 4 cores and 8gb ram. It shouldn't do that. Now its happy at 8% load at idle.
Thanks to those that tried to help.
had the same problem. not sure what causes this ridiculous performance nightmare, but eventually i had to re-install windows. This same issue was posted on Microsoft forums but the best answer was to re-install VS or windows.

Resources