Reputation: 5760
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?
Upvotes: 156
Views: 139385
Reputation: 139
I tried everything people said in this thread: Deleted DeriverData, pods, podfile.lock, workspace, pod cache, apple process in the Activity Monitor, re-started the laptop, re-started iPhone and removed app from the device, used a lower version of XCode I had installed in my laptop. Not sure what worked, but after repeating all this twice, and getting stuck again, I entered a 30 min meeting, when I came back to my XCode, the "paused indexing" was finally running.
Note: I was trying to run my react native app on my iPhone (OS version 17.3.1) with XCode 15.
Upvotes: 0
Reputation: 1
This issue happened to me, however it was an error message that didn't appear straight away and was stuck in the indexing loop. I had changed an object from an array of objects to just an object in my ViewModel, all the while forgetting to update my code on my View. This caused the looped indexing as it would not resolve an array of objects into the view (as it did not exist anymore!). I simply had to delete that code, replace it with using values for a single object.
Upvotes: 0
Reputation: 500
in my Case : make the UIViewController inherent from self
Like That :
class HomePosVC: HomePosVC { }
Upvotes: 0
Reputation: 2082
This worked for me
Upvotes: 0
Reputation: 2124
This happened to me. If you are using cocoapods do this:
project.xcworkspace
pod install
on the terminalproject.xcworkspace
project.xcworkspace
Upvotes: 7
Reputation: 1164
I know this is a pretty old question, but the issue still exists. Here's what I found experiencing this.
Inside a NavigationLink, I was giving a parameter to a View that didn't take one. It hung the build and indexing, but didn't kick a compiler error. That is NOT cool.
Here's how I reproduced it. Inside a top level view that contains a Navigation View, I had the following block inside a List inside a Stack. So my top level view's hierarchy was something like (pseudocode):
Body {
VStack {
[CustomViewForPageHeader]
List {
(the code block pasted below)
(some other things)
}
}
}
The offending part was this:
if 0 < viewModel.taskUpdates.count {
Section( "Chore updates"){
ForEach(viewModel.taskUpdates, id:\.id){ update in
if "complete" == update.statusType {
NavigationLink {
CompletedTaskApprovalView( update: update )
} label: {
Text(update.formattedMessage)
.padding(.vertical)
}
}
if "reject" == update.statusType {
Text(update.formattedMessage)
.padding(.vertical)
}
}
}
}
Remembering that I had removed the parameter while restructuring some data, I was dismayed that the compiler didn't puke on this. I commented out the whole line, so it looked like:
if 0 < viewModel.taskUpdates.count {
Section( "Chore updates"){
ForEach(viewModel.taskUpdates, id:\.id){ update in
if "complete" == update.statusType {
NavigationLink {
//CompletedTaskApprovalView( update: update )
} label: {
Text(update.formattedMessage)
.padding(.vertical)
}
}
if "reject" == update.statusType {
Text(update.formattedMessage)
.padding(.vertical)
}
}
}
}
And lo and behold, whammo, it worked just fine.
Uncommented it and removed the parameter...
if 0 < viewModel.taskUpdates.count {
Section( "Chore updates"){
ForEach(viewModel.taskUpdates, id:\.id){ update in
if "complete" == update.statusType {
NavigationLink {
CompletedTaskApprovalView()
} label: {
Text(update.formattedMessage)
.padding(.vertical)
}
}
if "reject" == update.statusType {
Text(update.formattedMessage)
.padding(.vertical)
}
}
}
}
whammo, redux, again, worked fine.
I had everything stripped out of the CompletedTaskApprovalView while I was reworking the data model a little bit, so it looks like this (literally just a place holder):
import SwiftUI
struct CompletedTaskApprovalView: View {
var body: some View {
Text("Approve chores")
.font(.title)
}
}
The compiler never should have let me try to hand it a parameter. So I thought that was weird, and I wondered if my view's code file had some kind of funky non-visible corruption. Inside the top level view's file, I added a new view (SomeTestView) at the bottom...
struct SomeTestView: View {
var body: some View {
Text("this is just a thing")
}
}
and added it to my loop..
if 0 < viewModel.taskUpdates.count {
Section( "Chore updates"){
ForEach(viewModel.taskUpdates, id:\.id){ update in
if "complete" == update.statusType {
NavigationLink {
//CompletedTaskApprovalView()
SomeTestView()
} label: {
Text(update.formattedMessage)
.padding(.vertical)
}
}
if "reject" == update.statusType {
Text(update.formattedMessage)
.padding(.vertical)
}
}
}
}
Works fine.
Added a parameter to the instantiation above (but did NOT add one to the view's Struct definition)... and it behaved the same as the original issue - hung up the build and the indexing, seemingly endlessly, and never puked the parameter error I'd expect.
if 0 < viewModel.taskUpdates.count {
Section( "Chore updates"){
ForEach(viewModel.taskUpdates, id:\.id){ update in
if "complete" == update.statusType {
NavigationLink {
//CompletedTaskApprovalView()
SomeTestView( fish: "sandwich" )
} label: {
Text(update.formattedMessage)
.padding(.vertical)
}
}
if "reject" == update.statusType {
Text(update.formattedMessage)
.padding(.vertical)
}
}
}
}
So that's freaky and 100% disappointing. I'm steering clear of diagnosing it further, but... if anyone is still running into this, give that a try; check out your parms and declarations carefully, and maybe you'll find a similar hiccup.
Weird. Frustrating. Confusing. Annoying.
Upvotes: 0
Reputation: 11416
com.apple.dt.SKAgent
If did not help:
rm -rf ~/Library/Developer/Xcode/DerivedData
If did not help:
If did not help:
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
Upvotes: 3
Reputation: 1735
Yes each time I try to open my Main.Storyboard Xcode freezes suddenly. This was happening with only one of my projects then it happens to all my projects on Xcode.
Tried the following with no luck:
Remove Xcode & reinstall it.
Factor reset my mac.
Create a new project and move folders to the new project. Also not worked for me.
Solution [In my case], which I believe it happens to most of you.
I have noticed that process named "IBAgent-iOS" consumes most of my CPU resources. Each time I want to open the storyboard it consumes up to 97% of CPU resources!
So I need to go to Activity Monitor > Search for this process name "IBAgent-iOS" (Mainly appears at the top) > click on it and Force Quit.
Upvotes: 0
Reputation: 143
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)
Upvotes: 2
Reputation: 794
Had this problem on a SwiftUI project. Turned out one of my SwiftUI views had an incorrectly declared variable. I had:
@EnvironmentObject var roomViewModel
where I needed:
@EnvironmentObject var roomViewModel: RoomViewModel
There was no compiler error, just endless indexing. After I fixed the error, the project built quickly.
Upvotes: 0
Reputation: 413
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.
Upvotes: 11
Reputation: 889
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!
Upvotes: 0
Reputation: 2127
com.apple.dt.SourceKitService
process. Then XCode would start to index again instead of stuck.Upvotes: 8
Reputation: 9156
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
Upvotes: 3
Reputation: 186
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
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.
Upvotes: 1
Reputation: 91
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.
Upvotes: 0
Reputation: 388
For XCode 9.3 indexing issue - Uninstall the XCode and instal again from zero. Works for me.
Upvotes: 0
Reputation: 363
rm -rf ~/Library/Developer/Xcode/DerivedData
Upvotes: 24
Reputation: 1177
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)
Upvotes: 0
Reputation: 2332
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.
Upvotes: 4
Reputation: 4246
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.
Upvotes: 2
Reputation: 9367
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
}
Upvotes: 0
Reputation: 1621
I fixed this by simply deleting the app from my device and rebuild.
Upvotes: 0
Reputation: 2823
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 :-)
Upvotes: 0
Reputation: 102
I too was facing the problem. I noticed that I have opened the same project twice.
So QuitXCode > Open your project and make sure only one instance is open > Clean > CleanBuild Folder in some cases > build.
It should work
Upvotes: -2
Reputation: 44
Close Your Xcode , close any git client(source tree or terminal)if it is opened and finally restart your project.
Upvotes: 0
Reputation: 346
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)
Upvotes: 0