I'm trying to convert one of my projects from purely Objective-C into Swift, but keep running into a problem with Xcode. With any Sprite Kit, Obj-C, or Obj-C/Swift project, everything will index, clean, build, and run successfully. However when the project is just comprised of .swift files, Xcode hangs on indexing and building, and won't do anything else. I've tried disabling indexing, nuking the DerivedData folder, even completely re-installing Xcode 6 along with the associated library files, but nothing seems to work. Any ideas on how to fix this?
-
1It's a beta...report this as a bug? – nneonneo Jun 06 '14 at 15:41
-
This could be a bug, or not. But could you make a self-contained example, so that others can at least try to find what is going wrong. (You could make a minimal example that shows this behaviour and post it on Github). – Unapiedra Jun 06 '14 at 15:49
-
1Same problem here. I created a single view project purely out of swift and Xcode just keeps indexing forever, slowing down the whole computer. In Activity Monitor there is a process called "swift" that takes up a ton of memory and CPU. I have to force quit that process. – aeubanks Jun 06 '14 at 19:42
-
1I've hit it too. Tried restarting Xcode and rebooting, no fix. Indexing takes up 300% CPU (on a 4 core machine) and building does not seem to run at all, it waits for indexing to finish I think. – Abhi Beckert Jun 09 '14 at 12:27
-
Also having the same issue. Found another similar issue here: http://stackoverflow.com/questions/24310246/xcode-6-beta-not-compiling (No Solution here either) – Matthew Knippen Jul 07 '14 at 04:35
-
i've got the exact same problem as well. – mildog8 Jul 13 '14 at 02:23
-
I face the same problem today... ends up that I have a nil in my array which causes the hang up! – Lim Thye Chean Jul 25 '14 at 04:31
-
This has been an on and off problem for years. Obviously, the Swift compiler needs some work. A well-designed compiler should be able to handle any level of code complexity with ease. It's somewhat concerning that it seems to be unable to do so. – William T Froggard Jun 25 '17 at 16:50
7 Answers
I've tracked this down to some particular source code I was using (specifically tuples inside an array) that lock up the indexer.
There doesn't seem to be any workaround except to avoid having that particular source code in the project.
I filed a bug with Apple, Radar number 17241603.

- 32,787
- 12
- 83
- 110
-
Just hit this myself trying to use tuples in general (not inside an array). I did have a rollback point I was happy with so I had to completely delete the method with the tuples (changing it to only return a single value didn't seem to help). It was only once Xcode was restarted that the SourceKitService stopped using up all my RAM. It seems to sit around 50MB normally but it had hit 6GB Was quite a vicious cycle I ended up in as it would very quickly eat all my memory and grind the computer to a halt. – Hobsie Jul 25 '14 at 11:52
-
This bug will relate to our project state and source code. I rolled back some commits of my project, xcode succeeded indexing my project.
In my case, xcode failed to index, when my project has a declaration of large dictionary. (I succeed indexing after removing it.)

- 3,162
- 2
- 25
- 32
-
Thanks I just commented out some Array literals, and now my project builds. Your dictionary issue made me think to try it :) – o.uinn Jul 29 '14 at 05:17
-
A big thanks from me also. Moving out part of the inner dictionary to a separate declaration allowed my project to build. – worriorbg Jan 14 '16 at 12:37
I had the same problem, and I could find the solution when analyzing the following code
func toDictionary() -> NSDictionary {
return [
"smartCoins" : smartCoins ?? 0,
"name" : name ?? "",
"birthDate" : birthDate ?? "",
"photo" : photo ?? "",
"gender" : gender ?? "",
"zoneId" : zoneId ?? "",
"cityId" : cityId ?? "",
"username" : username ?? "",
"id" : id,
"smartShopperIds" : smartShopperIds ?? [String](),
"followers" : followers ?? 0,
"voucherIds" : voucherIds ?? [String](),
"friend" : isFriend ?? false
]
}
It turns out that the ??
operator increases the compilation time. Therefore, when it was used a few times (one to three), the compilation time increases but finishes. However, when having more, the compilation never ends.
I hope this helps.

- 63,191
- 45
- 217
- 228
Hello I also faced the same problem and solved it.
go to product -> Click Stop. Until you see the indexing stops.
it worked for me. Try to stop the running if your not running
try it and tell me, if there's anything else.

- 623
- 2
- 7
- 16
There are no choices, you need convert it manually. No auto conversion so far.

- 23,382
- 43
- 130
- 308
I had the same issue with xcode 7 compiling forever. What I found is the initialization of map() in array caused the issue. I switched to use append() manually and the problem is solved. Here is the detail study http://applytech.me/blog/build-stuck-after-upgrading-from-xcode-6-to-xcode-7/ Hope it helps

- 1,165
- 1
- 11
- 24
XCode 8 beta 6 was hanging on Swift compilation for me. Turned out to be a circular reference in the class hierarchy. ie I had something like:
class Foo : Foo {
// etc
}
This came about through a refactoring from a more complex hierarchy, and I didn't notice. Clearly the compiler doesn't detect the cycle, and goes into an infinite loop :(.

- 1,059
- 12
- 20