[xcode] Xcode stuck on Indexing

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?

This question is related to xcode indexing freeze

The answer is


Also stop running app. if you have another application running with your xcode, stop it first and you should have your indexing continue.


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.


Hold alt > Product > Clean Build Folder


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.


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


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.


Close Your Xcode , close any git client(source tree or terminal)if it is opened and finally restart your project.


This happened to me. If you are using cocoapods do this:

  1. Delete project.xcworkspace
  2. Reinstall pods using 'pod install' on the terminal
  3. It will create a new project.xcworkspace
  4. Open the new project.xcworkspace -> Clean -> Build

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)


I fixed this by simply deleting the app from my device and rebuild.


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
{
    ...
}

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:

  1. Remove Xcode & reinstall it.

  2. Factor reset my mac.

  3. 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.


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 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


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)


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

  1. Remove some files
  2. Close Xcode
  3. Open Xcode
  4. 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.


For XCode 9.3 indexing issue - Uninstall the XCode and instal again from zero. Works for me.


  1. Close any opened Xcode
  2. rm -rf ~/Library/Developer/Xcode/DerivedData
  3. Right click your PROJECT_NAME.xcworkspace, choose 'show content', and delete 'xcuserdata' folder

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!


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

build settings flag

It will cause warning where the compiler take a long time to deduce a complex expression.

warning

This may cause a build error which will go away after you find the slow expressions and then remove the build flag.


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.


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.


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.


  • 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.

enter image description here


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)


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 :-)


  1. Close that project from Xcode
  2. Open Xcode Organizer, find the problematic project
  3. Delete Derived Data folder in the Organizer
  4. 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.


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.


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
}

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.


Command-Option-Shift-K to clean build folders.


Examples related to xcode

Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64 iPhone is not available. Please reconnect the device Make a VStack fill the width of the screen in SwiftUI error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65 The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1 Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Xcode 10: A valid provisioning profile for this executable was not found Xcode 10, Command CodeSign failed with a nonzero exit code

Examples related to indexing

numpy array TypeError: only integer scalar arrays can be converted to a scalar index How to print a specific row of a pandas DataFrame? What does 'index 0 is out of bounds for axis 0 with size 0' mean? How does String.Index work in Swift Pandas KeyError: value not in index Update row values where certain condition is met in pandas Pandas split DataFrame by column value Rebuild all indexes in a Database How are iloc and loc different? pandas loc vs. iloc vs. at vs. iat?

Examples related to freeze

Git push hangs when pushing to Github? Xcode stuck on Indexing