9,701 Points

Xcode playground gets stuck on 'running' and won't run the code, what to do?

Hi guys,

I have been following the Swift track for a while now but Xcode is messing with my progress. Every time I create a new playground in order to test some code, Xcode gets stuck and won't run the code. It simply presents a promising 'running' statement at the top of the screen but nothing happens no matter how long I wait.

I am running Xcode 8.0 on macOS Sierra 10.12. Hardware: MacBook Pro (13" Mid-2012) 2,5 GHz Intel Core i5 4 GB 1600 MHz Ram DDR3

Any ideas on solving? I have looked around but at least neither of these threads have provided an answer:

Things I have already tried with zero success:

  • Restarting Xcode
  • Reinstalling Xcode (downgraded to 7.3 but since that didn't help I upgraded back to 8.0)
  • Restarting the machine
  • Creating a new playground

Thank you in advance, cheers.

6 Answers

David Lin
David Lin
35,861 Points

Playgrounds are notoriously slow, because it's running in real-time and responding to every change. If you have commands that are computationally heavy (e.g. processing through huge arrays, etc.) that will bog things down significantly. Also, I've noticed it helps speed things up in the Playground to create classes/structs/enums/etc in separate files in the file manager to the left, just as you would a real project.

9,701 Points

Thank you for your quick reply, David. The problem is that in my case Xcode's behaviour is not actually caused by complex code. The forementioned freezing happens even if I am simply trying to print a single statement to the console. The problem must thus be somewhere else.

Yesterday I left the playground running and after some 20 minutes Xcode printed this to the console:

Playground execution failed: error: Couldn't lookup symbols:

thread #1: tid = 0xc0cd0, 0x000000010ea7c3c0 MyPlayground`executePlayground, queue = '', stop reason = breakpoint 1.2

frame #0: 0x000000010ea7c3c0 MyPlayground`executePlayground 
frame #1: 0x000000010ea7b9c0 MyPlayground`__37-[XCPAppDelegate enqueueRunLoopBlock]_block_invoke + 32 
frame #2: 0x000000010f59625c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
frame #3: 0x000000010f57b304 CoreFoundation`__CFRunLoopDoBlocks + 356
frame #4: 0x000000010f57aa75 CoreFoundation`__CFRunLoopRun + 901
frame #5: 0x000000010f57a494 CoreFoundation`CFRunLoopRunSpecific + 420
frame #6: 0x0000000114985a6f GraphicsServices`GSEventRunModal + 161
frame #7: 0x0000000110124f34 UIKit`UIApplicationMain + 159
frame #8: 0x000000010ea7b6e9 MyPlayground`main + 201
frame #9: 0x0000000112ad268d libdyld.dylib`start + 1
frame #10: 0x0000000112ad268d libdyld.dylib`start + 1 

Does anyone have an idea what this implies?

David Lin
David Lin
35,861 Points

Hmm, exactly what statement are you trying to print? Seems like your playground isn't happy with it. You might try re-installing XCode just to see if that helps. Or, can you post your playground at some file-sharing site or GitHub and provide the link here? I can help test it with you.

9,701 Points

Thanks again David for your effort and sorry I have kept you waiting. I have reinstalled Xcode multiple times without any luck and even tried an older version of the software (see the original post). The content of the playground in which I received the error message posted above was nothing else but:

print("Some text")

The same problem happens with me when testing a very simple function, I have a MBPr15" (Late 2013) with Sierra 10.12.6

Matthew Jeng
Matthew Jeng
9,242 Points

I'm also encountering this problem on very simple code. If anyone has found a solution please do tell.