I'm currently developing an iOS app using swift and Xcode 6 (Beta 3).
Everything went fine so far but now as my project grows, Xcode suddenly began indexing and it does that again and again, making Xcode nearly unusable.
I have searched the web for similar problems and tried the solutions but none of them did help.
Even disabling the indexing process (defaults write com.apple.dt.Xcode IDEIndexDisable 1) does not stop Xcode to do that.
While indexing, my CPU usage goes up to 300%+, causing the fans to run at highest speed.
In Activity Monitor there are several tasks named "swift" taking up about 1GB memory each.
Killing the processes named 'swift' and then checking the error in xcode will give you the part of the code giving you trouble. There are some bugs in swift that needs to be circumvented.
To kill the process: Applications > Utilities > Activity Monitor. Then find the "swift" process, double click and choose Quit or Force Quit.
Happened to me with Xcode 7.3
Had to clean everything Xcode had cached to solve it.
Solution:
rm -frd ~/Library/Developer/Xcode/DerivedData/*
rm -frd ~/Library/Caches/com.apple.dt.Xcode/*
I had this same issue and it took me FOREVER to solve it. I'm pretty sure I've seen every question on the internet about this issue and I tried all of the solutions. Turns out all I had to do was....
Restart my computer
Solved it: I deleted the most recently added files from the project and the problem disappeared. Then I started to add back the files, one by one until the problem reappeared. So I found the file causing the problem. Then I deleted the most recently added code from that file and again, the problem disappeared.
That way, I found a piece of code which was responsible for that behavior.
I had the same issue in my code. The solution for me was delete all spaces in the array in my code.
Ex.
struct Objects {
let objectA = ["text1",
"text2",
"text3",
"text4"] }
// Noise, CPU 100% and Index forever. The solution is...
struct Objects {
let objectA = ["text1","text2","text3","text4"]}
// Solved making the Array or String with no space.
I had that problem when I was at the swift crunch in krakow a couple weeks ago. We had the code on github, experienced that indexing problem on a macbook, we tried pulling the repo on 2 other macbooks, same result.
It's clearly a bug, I don't know what is causing it, we tried whatever we could think of (clean, clean build folder, manually removing files not in the repo, rebooting, killing processes, etc.), and after a couple hours the only thing left to do was creating a new xcode project from scratch and manually importing the files from the other project.
Never happened again since then, neither on that nor on other projects.
For me, I made a stupid mistake. I write a Class like this:
class A: A {
.......
}
A class inherit itself that causes the freezing. There is no message hint from Xcode. You can just take this as possible reason ~ .
It's Xcode bug. Problem caused with concatenation in one line:
var value = "some text" // it can be String or Array
value = value + value1 + value2 + value3 + value4 + value5 + value6 // etc
This correction fixes this bug:
var value = "some text"
value += value1
value += value2
value += value3
value += value4
value += value5
value += value6
I was creating a dictionary like this
var dic1 = [
"isDestination" : self.isDestination ?? false,
"price" : self.price ?? ""
]
and self.price is of type Int and I was giving its fallback value as an empty string which screwed up the Xcode compilation.
I got this issue and 6 hours later (after trying everithing and build new project again step by step copying resources) I FOUND MY PROBLEM:
class A : A {
...
}
By the fact of copy/paste I had a class that extends itself, and this makes indexing crazy.
It's definitely a Xcode bug and I reported that to Apple. When you have a large dictionary literal or a nested dictionary literal. You have to break your dictionary to smaller parts and add them with append method until they fix the bug.
Xcode 8.2.1 (8C1002)
I had the same problem with one call adding 11 NSLayoutConstraint objects to an array.
The solution was to divide the code into several calls, each adding only 3 objects to the array. Weird.
That was in Xcode 6.4
Too many string concatenations in one line cause troubles. Helped me too.
Originally was pointed by Zhenshan Yu there: Xcode 6 Beta not compiling
I had this issue with XCode 6.3 when creating a C++ project. Before switching over to developing in SubLime, my last ditch effort was to delete the XCode app and reinstall. It was a long process, but my version of XCode is now updated to 7.3 and everything is working as it should.
So if nothing else seems to be working, you could try deleting XCode from your applications folder and then reinstalling. Just be sure you aren't deleting any project files you want to keep.
Mine was about dragging a new file with String extension to the project and not adding it to all required targets.
Hope that helps someone.
Backup your project delete the lastone and restart the xcode simple :-)
I too faced the same issue for Xcode 9.1.
So i looked into Activity Monitor. There was swift process which was above 100%. Double Clicked it and Quit.
Done. Now its working fine.
I went to tools->task and contexts->clear contexts and that seemed to give the computer rest finally!
enter image description here
I got this issue when my Xcode was 9.2 . First I deleted xcworkspace file ,cleaned and built according to the others' answer.But it did not work.
Then I updated Xcode to 9.3 It also did not work. I checked my code and found that the recently written code made Xcode Indexing forever:
TimeInterval(3600*24*(-randomDay))
Then I amended it:
TimeInterval(-3600*24*randomDay)
It worked.
I find that many situations can cause Xcode to work abnormally.So I think the correct solution is that think about what you've done for your project recently
In my case the issue was caused by some aritmetic sums.
I was creating a collectionView with all the different frames programmatically doing it like this:
cell.textView.frame = CGRectMake(8 + 10 + 12, 0, 150 + 6 + 6 + 4, 50)
I just changed it to:
cell.textView.frame = CGRectMake(30, 0, 166, 50)
It helps me figure out the margins and paddings more easily, but just puting the result of the sum changed the build speed from 5 - 7 minutes to 20 seconds or so.
Yet one possible thing, that may cause such behavior:
For debugging purpose I changed system time, set up in one week ago - and I've got infinite indexing. As soon, as I set time back - indexing has stopped.
in my case i had the emulator open with an app builded with previous files. Just close de emulator
I've tried all the things listed, indexing is keep freezing.
This helped me:
If your indexing is freeze, and you have one or more swift process eating 99% of your cpu - just kill this swift task(s), wait a bit, and progress should move.
It can repeats, until it reaches finish, in my case I killed the process 7 times, but at the end, indexing was completed!
For me it was circular inheritance causing the issue:
class CustomButton: CustomButton {
...
}
And various other recent find/replace errors in the code. Xcode wasn't highlighting them as errors and just kept indexing.
I recognized today, that running Apples Playgrounds application alongside Xcode I have that very same symptoms. and maybe that was the root cause in earlier situations. So in my case, closing Playgrounds did the trick.
My particular problem was a fairly long literal dictionary containing much data.
My solution was to understand that Xcode indexing wasn't "stuck", but just taking a long time.
So I only had to wait more time than I expected.
Non of the answers helped in my case. I tried multiple things like:
Device and Simulators - Wifi connected device
Disconnect all devices which can be connected with wirelessly.
Removing Xcode's cache, derived data:
rm -frd ~/Library/Developer/Xcode/DerivedData/*
rm -frd ~/Library/Caches/com.apple.dt.Xcode/*
Deleting defaults for Xcode
defaults delete com.apple.dt.Xcode
Solution
What helped in my case was to rename project folder. Once I did that everything started working again.
In my case, I tried all the suggestions I found on the internet but nothing worked.
The solution that worked for me was to run another project on xcode that could be indexed, and once indexing was done I closed xcode and opened it on the first project that had indexing issues, and it works.
No idea why, but it works :)
This is a workaround I posted on another stackoverflow thread related to Xcode indexing problem. This question looks to be more swift related but my workaround can probably be useful here too. So here it is. My project is very big (merging objective c, c++, swift, and java files with j2obj) and none of the answers here solved the indexing problem. The idea is to limit the CPU usage of the Xcode indexing process with an external tool like cputhrottle.
So first you need to install cputhrottle in terminal
brew install cputhrottle
Then limit the Xcode indexing process like this (20 = 20%)
sudo cputhrottle $(pgrep -f com.apple.dt.SKAgent) 20
I've exposed my "solution" here with more details : How to prevent Xcode using 100% of CPU when indexing big projects
Related
Ok, so I'm taking a udemy course on UE4 and when compiling I have a issue where I'm presented with my file location and told it exited with code 6. There are also a lot of errors saying that say it can't read my macros - how do I fix this? I'm relatively new to this so try to make it as simple as possible when answering. Thank you.
I would advise paying close attention to syntax and UPROPERTY (what is in here).
For example, I had this situation:
struct FGridCoord
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Grids")
int Col = 0;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Grids")
int Row = 0;
/** Default constructor (no initialization). */
FORCEINLINE FGridCoord() {} <<<------ This was giving same error ---->>> FORCEINLINE FGridCoord();
And other one I had:
UPROPERTY(VisibleAnywhere, Category = "Grids", meta = (AllowPrivateAcsess = "true")) <<<---- It had BlueprintReadOny and was giving an error
USceneComponent* RootComp;
I was getting the exact error this question lists (also taking a Udemy course on Unreal LOL), syntax all looked fine (this project/environment worked fine the last time I used it, some months ago) and hadn't changed, so I decided to clean the solution and rebuild.
This time I got a slightly different error, and it mentioned needing Windows SDK installed.
A quick Google of that seems to show that yeah, that's what's needed. Visual Studio Installer showed under C++ Game Development that none of the Windows SDK options were checked/installed. Since I'm running Windows 10 I checked the most recent/highest version of W10SDK and installed that.
After that I tried loading my project from the Epic Games Launcher, just like I did before starting my Udemy course 30 minutes prior. Now that said it was missing a module and that it needed to be rebuilt. Clicked "OK." The project rebuild failed.
I saw Unreal Engine could be updated from 4.27.1 (which I created my project in and which had been working without issue some months ago, like I said) to 4.27.2. Downloaded the 4GB update, still got the "missing module, rebuild" error but after clicking "OK" that time it built and UE 4 opened the project. VS2022 now builds the solution, and I can play the project within UE 4.
I have no fricking clue what just happened here, cause this all worked last time I worked on it and I changed nothing in the meantime, but it all works now.
So for others that get this, maybe:
Try cleaning your solution and see if you perhaps need to install Windows SDK
Maybe upgrade your UE 4 a minor version, if it's available
Head asplodes 🤷♂️🤷♂️🤷♂️
A project I've been working for 2 months stopped working for no reason because Xcode got stucked on "Indexing". I can't Build the project anymore. If I try to build, Xcode freezes and I have to force quit. This happens only with this project.
I tried cleaning all derived data but didn't help.
I'm using Xcode 4.5.2.
Any ideas?
Open your Project Folder.
Find ProjectName.xcodeproj file.
Right-Click Copy and Paste to Safe Place.
Right-Click Show Package Contents.
Find project.xcworkspace file and delete that file.
Reopen Your Project and clean and Rebuild.
If your problem is not solved then replace the file with your backup file.
Close that project from Xcode
Open Xcode Organizer, find the problematic project
Delete Derived Data folder in the Organizer
Close/re-open Xcode
Nuking Derived Data is the first thing to try in all cases of Xcode misbehaving
I had this exact problem, it was caused by a 20 item array literal. Had to switch to different syntax. Pretty silly.
Close any opened Xcode
rm -rf ~/Library/Developer/Xcode/DerivedData
Right click your PROJECT_NAME.xcworkspace, choose 'show content', and delete 'xcuserdata' folder
Another thing to try if your trying to solve indexing issues and you're this far down the page!
Try adding this flag to your build settings.
-Xfrontend -warn-long-expression-type-checking=400
It will cause warning where the compiler take a long time to deduce a complex expression.
This may cause a build error which will go away after you find the slow expressions and then remove the build flag.
I had a similar problem, and found that I accidentally defined a class as its own subclass. I got no warning or error for this but the compiling got stuck.
class mainClass : mainClass
{
...
}
When using Xcode 6 and it says
Waiting for make
It might be that an instance of make is already running. Kill the process and indexing proceeds. Silly, but worked for me.
This happened to me. If you are using cocoapods do this:
Delete project.xcworkspace
Reinstall pods using pod install on the terminal
It will create a new project.xcworkspace
Open the new project.xcworkspace
-> Clean
-> Build
First, disconnect from network. Both your wired network and wireless network should turn off.
Second, kill the com.apple.dt.SourceKitService process. Then XCode would start to index again instead of stuck.
Hold alt > Product > Clean Build Folder
It's a Xcode bug (Xcode 8.2.1) and I've reported that to Apple, it will happen when you have a large dictionary literal or a nested dictionary literal. You have to break your dictionary to smaller parts and add them with append method until Apple fixes the bug.
For me completely closing out of Xcode and then restarting the project worked.
This is not the solution for the original question, I don't believe, but it is one more simple thing to try before deleting files and folders, etc. Credit to this answer for the idea.
I had a similar problem where Xcode would spend lots of time indexing and would frequently hang building the project, at which point I had to force-quit and relaunch Xcode. It was very annoying.
Then I noticed a warning in the project about improperly assigning self as a delegate. Sure enough, there was a missing protocol in the class declaration. Note that there is a similar assignment in the OP's sample code (though it is impossible to tell from the sample whether the correct protocol is declared):
leaderboardController.leaderboardDelegate == self;
After resolving that warning (by correctly declaring the implemented protocol), Xcode stopped misbehaving. Also, I should note that the project did execute correctly since the protocol methods were implemented. It was just that Xcode could not confirm that the protocol should in fact implemented by the class.
For me, I made a stupid mistake. I write a Class like this:
class A: A {
.......
}
A class inherit itself that causes the freezing. There is no message hint from Xcode.
Nothing worked for me, my project is too big (merging objective c, c++, swift, and java files with j2obj). I've disabled Xcode indexing and worked without code completion for months (and it's a pain). But finally I've found a workaround. The idea is to keep Xcode indexing the code, but to limit its CPU usage with an external tool like cputhrottle.
So first you need to install cputhrottle in terminal
brew install cputhrottle
Then limit the Xcode indexing process like this (20 = 20%)
sudo cputhrottle $(pgrep -f com.apple.dt.SKAgent) 20
I've exposed my "solution" here with mode details : How to prevent Xcode using 100% of CPU when indexing big projects
I'm working with Xcode 11.4.1 and I have the same problem with several projects. Every time, when internet connection is lost, indexing gets up. The best solution (it's just my opinion based on observing this problem):
- turn off internet and just kill the "com.apple...." process, then restart the Xcode(turn on connection)
or more easier
- just restart the Mac(with the internet)
Had similar problem in Xcode 6.4. The progress bar indicated that "Indexing" was "Paused". Tried deleting project.xcworkspace, then deleting Derived Data as described above. Did not appear to help. Noting that the posts above also suggest fixing warnings, and since I had inherited this huge project with 180 warnings, I said to myself, "What the hell this looks like a good day to fix warnings". As I was fixing warnings, a half hour later, I noticed that the "Indexing" progress bar had increased from 10% to about 20%. An hour later, it was at 50%, then another hour to 80%, then after another half hour it was done! Conclusion: Add "take a long lunch or a nap" to the above suggestions.
I experienced the same issue for Xcode 7.0 beta.
In my case, values for "Provisioning Profile" and "Product bundle identifier" of "Build Settings" differed between PROJECT and TARGETS.
I set the same values for them. And I also used the same values for TARGETS of "appName" and "appNameTest".
Then closed the project and reopened it.
That resolved my case.
In my case, deleting the derived data directory did not help. Apparently I had a file locked by another process, because after closing out a couple of terminal windows and emacs, and terminating a react-native packager process, everything resolved.
I have experienced this problem in some projects with Xcode 9.3.1 and in my case the problem is due to some swift code that for some reason Xcode doesn't like. This problem is hard to solve because is difficult to find what file is causing the problem.
When I have this problem, I removing some files from the Xcode project (removing references) and I try to test if indexing works. My process to do so
Remove some files
Close Xcode
Open Xcode
If indexing finish try to rename some method if works probably the files you have removed they have something strange for Xcode.
In my case I had a class definition with a reactive extension in the same file and for some reason Xcode doesn't like it, I moved the reactive extension to another file and now the indexing works fine.
2022 | Algorithm what to do:
Open activity monitor and kill there com.apple.dt.SKAgent
If did not help:
Close Xcode(cmd+Q). Run command in terminal:
rm -rf ~/Library/Developer/Xcode/DerivedData
If did not help:
Restart PC
If did not help:
Right click your PROJECT_NAME.xcworkspace, choose 'show content', and delete 'xcuserdata' folder
If did not help:
run your project build with additional warning. For doing this you need to write:
-Xfrontend -warn-long-expression-type-checking=100
to the following place:
and optimize code at all of places.
If did not help:
Z. Uninstall XCode and install it from scratch
If did not help:
Z+1. answer of El Belga https://stackoverflow.com/a/50541767/4423545
Also stop running app. if you have another application running with your xcode, stop it first and you should have your indexing continue.
For me, the cause was I opened the same file in both the Primary Editor and Assistant Editor at the same time. Once I closed Assistant Editor, it came through. (Xcode Version 7.2.1)
Close Your Xcode , close any git client(source tree or terminal)if it is opened and finally restart your project.
Faced this recently on XCode 7.3.1 - for me, I noticed RAM usage going to 100% on to CleanMyMac3. The problem magically fixed itself after I restarted my machine. In all fairness however, I'd already gone ahead and tried the accepted-answer, so you'll want to do the same before you restart just in case :-)
I fixed this by simply deleting the app from my device and rebuild.
I had the same issue in swift 2.2
It had to do with a generic function overloaded function
func warnLog() {
print("Warning line: \(#line) file: \(#file) ")
}
func warnLog<T>(input:T? = nil) -> T? {
print("Warning line: \(#line) file: \(#file) ")
return input
}
func warnLog<T>(input:T) -> T {
print("Warning line: \(#line) file: \(#file) ")
return input
}
all I needed to do is remove one of the non used overloads
func warnLog<T>(input:T? = nil) -> T? {
print("Warning line: \(#line) file: \(#file) ")
return input
}
My case: it was not the project.xcworkspace file, it was not the Derived Data folder.
I've wasted a lot of time. Worse, no error message. No clue on the part of Xcode. Absolutely lost.
Finally this function (with more than 10 parameters) is responsible.
func animationFrames(level: Float,
image: String,
frame0: String,
frame1: String,
frame2: String,
frame3: String,
frame4: String,
frame5: String,
frame6: String,
frame7: String,
frame8: String,
frame9: String,
frame10: String) {
}
To go crazy! The truth is that it is worrisome (because there is no syntax error, or any type)
For XCode 9.3 indexing issue - Uninstall the XCode and instal again from zero. Works for me.
This issue happened to me when my machine was out of swap space. Closed several programs and browser tabs and the build suddenly succeeded after 30 minutes of being stuck in place. Nothing to do with derived data, locked files, etc. on my side.
This question already has answers here:
SourceKitService Terminated
(34 answers)
Closed 8 years ago.
Sometimes I get this error in Xcode 6 and the canvas turns white.
Am I the only one this happens to, or is it a bug?
I still have this issue.
I have a working solution:
If you are targeting on iOS8, switch the deployment target to iOS7,
If this issue happen again, switch the deployment target to iOS8,
If this issue happen again, switch the deployment target to iOS7,
If this issue happen again, switch the deployment target to iOS8,
...
...
...
Hope this help you.
Update:
Seems this is better solution:
Quite Xcode, and delete all the folders in the DerivedData directory
I use Xcode 6 beta5, when I declare member as lazy, it will show this error when I enter new line. It works when I remove the keyword lazy.
class PointZoomingView : ZYZoomingView, CMPopTipViewDelegate
{
private ***lazy*** var pointButtonList: [PointButton] = []
var hwRate: Double! = 1
[UPDATE]
If your [PROJECT_NAME]-Bridging-Header.h import a non existing header file, the SourceKitService will be Terminated frequently
SourceKit appears to simply be very, very bad.
The list of problems above contains a number of possible causes; beta software, code being updated across releases (created in one version, edited in another), problems with IB connections, bridging or issues with override and/or lazy.
Well I'm using the release version of Xcode 6.1. The code was created in this version. There isn't a single use of overrides, lazy or bridging. It does file handling, and doesn't have a single IB connection (yet). The code is entirely devoted to opening text files and parsing them, using the most basic Cocoa primitives, mostly NSString.
SourceKit crashes every couple of minutes. It crashes so often and randomly I cannot determine any sort of pattern. One issue appears to be if an existing line of code contains a reference to one type and then changes to another, but that's definitely not sure-fire nor the only cause. (Update: crashes with every 10th or so keystroke now)
I was having a problem with xcode 6 beta 6. I finally changed the iOS Deployment Target from 7.0 to 7.1 and my problem went away!
You should report a bug to apple as Xcode is in beta mode so don't expect it to work fine. Although there are many points at which this occurs in my case it was occurring randomly or by writing piece of code in between [].
Download the latest version of Xcode 6 beta and enjoy coding...
an update released in Dec 2, 2014, related to this error.
Please make sure your xcode latest.
Xcode, Apple Version 6.1.1 Released Dec 2, 2014
Includes SDKs for OS X 10.10 Yosemite, OS X 10.9 Mavericks, and iOS 8.1
- Fixed common causes of SourceKit crashes when working with Swift
- Additional bug fixed and stability improvements
Try rewriting the methods you have defined/overrided.
I faced this problem when I updated my Xcode6 from beta 3 to beta 4. Xcode6 beta 4 differs in the IBOutlet declaration and treats IBOutlet declarations of Xcode6 beta 3 as errors. When I changed the declarations(of Xcode beta3) with beta 4 this SourceKit Service error popped up.
What I did to fix my code :-
Removed all the methods of tableview delegate and datasource and write them again. Now everything works just fine.
I can confirm that this command on terminal solves it
rm -rf ~/Library/Developer/Xcode/DerivedData/ModuleCache
.. delete all the Content of the DerivedData folder .. apparently there are project based files and moduleCache may be a general one, and by deleting only the moduleCache the problem can still remain in the project based files
A project I've been working for 2 months stopped working for no reason because Xcode got stucked on "Indexing". I can't Build the project anymore. If I try to build, Xcode freezes and I have to force quit. This happens only with this project.
I tried cleaning all derived data but didn't help.
I'm using Xcode 4.5.2.
Any ideas?
Open your Project Folder.
Find ProjectName.xcodeproj file.
Right-Click Copy and Paste to Safe Place.
Right-Click Show Package Contents.
Find project.xcworkspace file and delete that file.
Reopen Your Project and clean and Rebuild.
If your problem is not solved then replace the file with your backup file.
Close that project from Xcode
Open Xcode Organizer, find the problematic project
Delete Derived Data folder in the Organizer
Close/re-open Xcode
Nuking Derived Data is the first thing to try in all cases of Xcode misbehaving
I had this exact problem, it was caused by a 20 item array literal. Had to switch to different syntax. Pretty silly.
Close any opened Xcode
rm -rf ~/Library/Developer/Xcode/DerivedData
Right click your PROJECT_NAME.xcworkspace, choose 'show content', and delete 'xcuserdata' folder
Another thing to try if your trying to solve indexing issues and you're this far down the page!
Try adding this flag to your build settings.
-Xfrontend -warn-long-expression-type-checking=400
It will cause warning where the compiler take a long time to deduce a complex expression.
This may cause a build error which will go away after you find the slow expressions and then remove the build flag.
I had a similar problem, and found that I accidentally defined a class as its own subclass. I got no warning or error for this but the compiling got stuck.
class mainClass : mainClass
{
...
}
When using Xcode 6 and it says
Waiting for make
It might be that an instance of make is already running. Kill the process and indexing proceeds. Silly, but worked for me.
This happened to me. If you are using cocoapods do this:
Delete project.xcworkspace
Reinstall pods using pod install on the terminal
It will create a new project.xcworkspace
Open the new project.xcworkspace
-> Clean
-> Build
First, disconnect from network. Both your wired network and wireless network should turn off.
Second, kill the com.apple.dt.SourceKitService process. Then XCode would start to index again instead of stuck.
Hold alt > Product > Clean Build Folder
It's a Xcode bug (Xcode 8.2.1) and I've reported that to Apple, it will happen when you have a large dictionary literal or a nested dictionary literal. You have to break your dictionary to smaller parts and add them with append method until Apple fixes the bug.
For me completely closing out of Xcode and then restarting the project worked.
This is not the solution for the original question, I don't believe, but it is one more simple thing to try before deleting files and folders, etc. Credit to this answer for the idea.
I had a similar problem where Xcode would spend lots of time indexing and would frequently hang building the project, at which point I had to force-quit and relaunch Xcode. It was very annoying.
Then I noticed a warning in the project about improperly assigning self as a delegate. Sure enough, there was a missing protocol in the class declaration. Note that there is a similar assignment in the OP's sample code (though it is impossible to tell from the sample whether the correct protocol is declared):
leaderboardController.leaderboardDelegate == self;
After resolving that warning (by correctly declaring the implemented protocol), Xcode stopped misbehaving. Also, I should note that the project did execute correctly since the protocol methods were implemented. It was just that Xcode could not confirm that the protocol should in fact implemented by the class.
For me, I made a stupid mistake. I write a Class like this:
class A: A {
.......
}
A class inherit itself that causes the freezing. There is no message hint from Xcode.
Nothing worked for me, my project is too big (merging objective c, c++, swift, and java files with j2obj). I've disabled Xcode indexing and worked without code completion for months (and it's a pain). But finally I've found a workaround. The idea is to keep Xcode indexing the code, but to limit its CPU usage with an external tool like cputhrottle.
So first you need to install cputhrottle in terminal
brew install cputhrottle
Then limit the Xcode indexing process like this (20 = 20%)
sudo cputhrottle $(pgrep -f com.apple.dt.SKAgent) 20
I've exposed my "solution" here with mode details : How to prevent Xcode using 100% of CPU when indexing big projects
I'm working with Xcode 11.4.1 and I have the same problem with several projects. Every time, when internet connection is lost, indexing gets up. The best solution (it's just my opinion based on observing this problem):
- turn off internet and just kill the "com.apple...." process, then restart the Xcode(turn on connection)
or more easier
- just restart the Mac(with the internet)
Had similar problem in Xcode 6.4. The progress bar indicated that "Indexing" was "Paused". Tried deleting project.xcworkspace, then deleting Derived Data as described above. Did not appear to help. Noting that the posts above also suggest fixing warnings, and since I had inherited this huge project with 180 warnings, I said to myself, "What the hell this looks like a good day to fix warnings". As I was fixing warnings, a half hour later, I noticed that the "Indexing" progress bar had increased from 10% to about 20%. An hour later, it was at 50%, then another hour to 80%, then after another half hour it was done! Conclusion: Add "take a long lunch or a nap" to the above suggestions.
I experienced the same issue for Xcode 7.0 beta.
In my case, values for "Provisioning Profile" and "Product bundle identifier" of "Build Settings" differed between PROJECT and TARGETS.
I set the same values for them. And I also used the same values for TARGETS of "appName" and "appNameTest".
Then closed the project and reopened it.
That resolved my case.
In my case, deleting the derived data directory did not help. Apparently I had a file locked by another process, because after closing out a couple of terminal windows and emacs, and terminating a react-native packager process, everything resolved.
I have experienced this problem in some projects with Xcode 9.3.1 and in my case the problem is due to some swift code that for some reason Xcode doesn't like. This problem is hard to solve because is difficult to find what file is causing the problem.
When I have this problem, I removing some files from the Xcode project (removing references) and I try to test if indexing works. My process to do so
Remove some files
Close Xcode
Open Xcode
If indexing finish try to rename some method if works probably the files you have removed they have something strange for Xcode.
In my case I had a class definition with a reactive extension in the same file and for some reason Xcode doesn't like it, I moved the reactive extension to another file and now the indexing works fine.
2022 | Algorithm what to do:
Open activity monitor and kill there com.apple.dt.SKAgent
If did not help:
Close Xcode(cmd+Q). Run command in terminal:
rm -rf ~/Library/Developer/Xcode/DerivedData
If did not help:
Restart PC
If did not help:
Right click your PROJECT_NAME.xcworkspace, choose 'show content', and delete 'xcuserdata' folder
If did not help:
run your project build with additional warning. For doing this you need to write:
-Xfrontend -warn-long-expression-type-checking=100
to the following place:
and optimize code at all of places.
If did not help:
Z. Uninstall XCode and install it from scratch
If did not help:
Z+1. answer of El Belga https://stackoverflow.com/a/50541767/4423545
Also stop running app. if you have another application running with your xcode, stop it first and you should have your indexing continue.
For me, the cause was I opened the same file in both the Primary Editor and Assistant Editor at the same time. Once I closed Assistant Editor, it came through. (Xcode Version 7.2.1)
Close Your Xcode , close any git client(source tree or terminal)if it is opened and finally restart your project.
Faced this recently on XCode 7.3.1 - for me, I noticed RAM usage going to 100% on to CleanMyMac3. The problem magically fixed itself after I restarted my machine. In all fairness however, I'd already gone ahead and tried the accepted-answer, so you'll want to do the same before you restart just in case :-)
I fixed this by simply deleting the app from my device and rebuild.
I had the same issue in swift 2.2
It had to do with a generic function overloaded function
func warnLog() {
print("Warning line: \(#line) file: \(#file) ")
}
func warnLog<T>(input:T? = nil) -> T? {
print("Warning line: \(#line) file: \(#file) ")
return input
}
func warnLog<T>(input:T) -> T {
print("Warning line: \(#line) file: \(#file) ")
return input
}
all I needed to do is remove one of the non used overloads
func warnLog<T>(input:T? = nil) -> T? {
print("Warning line: \(#line) file: \(#file) ")
return input
}
My case: it was not the project.xcworkspace file, it was not the Derived Data folder.
I've wasted a lot of time. Worse, no error message. No clue on the part of Xcode. Absolutely lost.
Finally this function (with more than 10 parameters) is responsible.
func animationFrames(level: Float,
image: String,
frame0: String,
frame1: String,
frame2: String,
frame3: String,
frame4: String,
frame5: String,
frame6: String,
frame7: String,
frame8: String,
frame9: String,
frame10: String) {
}
To go crazy! The truth is that it is worrisome (because there is no syntax error, or any type)
For XCode 9.3 indexing issue - Uninstall the XCode and instal again from zero. Works for me.
This issue happened to me when my machine was out of swap space. Closed several programs and browser tabs and the build suddenly succeeded after 30 minutes of being stuck in place. Nothing to do with derived data, locked files, etc. on my side.
Since a few months ago, the code completion turned context-insensitive: it offers ALL the symbols starting with same letters in the same file, including words from the comments. On the other hand, it does not suggest anything from other files.
The problem survived cleaning all project data, reinstalling and upgrading Xcode and even upgrading the operation system.
from time to time I am having similar issues. Removing the DerivedData folder works for me.
here you'll find the same suggestion http://blog.slidetorock.com/xcode-4-code-sense-autocompletion-problems