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 'Running playground' or 'Launching simulator' statement at the top of the screen with the loading icon promisingly spinning next to it but nothing happens. Sometimes this continues indefinitely and sometimes Xcode halts and prints this to console :
Playground execution failed: error: Couldn't lookup symbols:
__swift_FORCE_LOAD_$_swiftCoreImage
__swift_FORCE_LOAD_$_swiftFoundation
_playground_log_hidden
_playground_logger_initialize
_playground_log_postprint
thread #1: tid = 0xc0cd0, 0x000000010ea7c3c0 MyPlayground`executePlayground, queue = 'com.apple.main-thread', 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
I am running Xcode 8.0 (8A218a) on macOS Sierra 10.12.
Hardware:
MacBook Pro (13" Mid-2012)
2,5 GHz Intel Core i5
4 GB 1600 MHz Ram DDR3
I have looked around but at least neither of these threads have provided an answer:
https://forums.developer.apple.com/thread/5902
https://github.com/jas/playground/issues/9
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
Do you have any ideas on how to solve this problem? I am new to programming and eagerly trying to learn Swift but Xcode is making it practically impossible.
Ans. Switch to macOS platform
When you create a Playground, by default it select iOS platform and automatically imports UIKit. It's the UIKit which crashes and stuck all the time. If your (practice) code does not use UIKit then you can switch to MacOS platform. As major (not exact though) difference between iOS and macOS is in APPKit and UIKit.
In the upper right corner of your Xcode Playground, click on show/hide Utilities--> file inspector --> Playground Setting--> Platform--> macOS
See screenShot below:
I have tried the following and it worked for me:
press on the bottom "stop playground" button
remove the first comment line and make import statement the first
line. no space above import.
press execute button
In my case, Xcode 8.3.2, it works when I try as steps below:
File -> Close "Name.playground"
File -> Close Playground
Quit Xcode
Re-open Xcode
Buggy Simulator's main process is still working even after Xcode closing. So here're the steps:
Quit Xcode;
Kill com.apple.CoreSimulator.CoreSimulatorService process in Activity Monitor;
Launch Xcode and run your Playground.
In my experience, you should:
Prevent Swift playground refresh, by holding: the ► arrow at the bottom left part of the Playground and selecting "Manually Run"
Quit Xcode
Restart Xcode
It works very well.
Adding import PlaygroundSupport solved the problem for me :)
I have cancelled the comment on the first line. It solved for me.
Make sure to try it after you have closed and relaunched Xcode and force quit com.apple.coresimulator from Activity Monitor
You can switch to manual processing. It worked for me.
Make sure you kill xcode in the activity monitor before eventually killing
com.apple.CoreSimulator.CoreSimulatorService process in the activity monitor. I tried killing the process a number of times and I realized if xcode is still running in the background activity then the com.apple.CoreSimulator.CoreSimulatorService process would pop up again even when you just killed it.
I had the same problem, all that I did is to open Assistance editor and everything works fine with me even when I closed the Assistance editor! Don't ask why it was trial and error. Hope this will help you
After beating my head on this for a few hours, I realized I had accidentally deleted this, VERY MUCH important line that allows to test UIKit elements before committing my playground onto git:
// Present the view controller in the Live View window
PlaygroundPage.current.liveView = MyViewController()
Facepalm. Hopefully this can help someone from pulling their hair out for a few hours.
I'm using Xcode 10.2 and am getting the same issue. So generally just use Online Swift Playground
This serves my purposes! :-)
In my case the problem was user-induced. I had the assistant editor displayed, but the live view wasn't selected. Make sure it looks like this:
And not like this:
For me, the issue was the fact that MyPlayground was syncing to iCloud.
Xcode saves your files every few seconds, and it leads to "not responding" states.
So there is a simple solution- just go to:
System Preferences - Apple ID - Apps on this Mac using iCloud- iCloud Drive - Options- And then uncheck "Playground"
That little trick helps to solve frozen "Running".
XCode 12.3 and still same issue happens.
Solution for me is Command + Q ( restart the Xcode )
after runnning a while you will see error message then you go to
view>debug area > activate console
and then play again
worked for me
Check for iCloud storage plan!
If you do have one, it constantly syncs the entire computer which includes Desktop and Document folders.
Instead try creating a "Local Files" folder in your Home folder(command+shift+h) and keep your Playground projects there, where it doesn't sync to iCloud.
This worked for me.I hope this works for you as well! :)
Also happens, like in my case, when you've defined a function, but have forgotten to call it?
As if this question didn't have enough answers, I will provide my "solution" to the stuck Swift playgrounds problem:
The one solution I've come across which works nicely for me (so I do not have to restart Xcode):
killall launchd_sim
This will cause the spinning "Running Playground..." to go away and you can trigger a new execution. Be aware: the next execution is going to spin up launchd_sim and all those child processes again. It would probably be best to kill only the relevant child process. But I didn't find it so far.
But I do this only when I'm not using the iOS Simulators in parallel, as the launchd_sim process is a child process of Simulator.
I deleted derived data and clean build folder. This works for me. I was facing with Xcode 11.2.1 and Xcode 10.1 on same machine.
To speed up the build in Xcode Playground and prevent the loading icon to keep spinning forever:
go to the sidebar on the right, and change iOS to macOS in Playground Settings
instead of importing UIKit, import Foundation
(this would work if you're not trying to use specific stuff from tthe UIKit framework)
I got this answer from : Ioannis Diamantidis - How to fix Xcode Playground getting stuck on "Running".
I am using Xcode version 13.2.1 with a Mac Mini M1.
I went to the playground icon on the top right corner - Hide or show the Inspectors, it says Playground Settings ,
I select in Platform macOs.
now my playground is running perfect, I see the results everywhere
I was facing the same issue but after googling and experimenting a bit, I found out that one must always import UIKit before importing any other libs.
Firstly, delete the inbuilt comment line.
Then, even if you put a first line comment back in, it still works.
One last tip that works for me:
Make sure no iOS simulator is running.
They conflict with each other.
My app crash on start up, on splash screen. After it crashes, double click home button, and I find that it is in "app gallery", just like as if it went to the background. Click it, splash window came again and this time, it launch normally. This very strange.
I've got the crash log, but I lost the dSYM file for some reason, so I can't exactly locate the bug. The crash log is just like this:
(yes, only one thread in crash log; there should be many in fact.)
0 CoreFoundation 0x0000000182538f60 <redacted> + 148
1 libobjc.A.dylib 0x0000000197087f80 objc_exception_throw + 56
2 CoreFoundation 0x0000000182538e90 <redacted> + 0
3 stockmap-ios 0x00000001005d6fc4 stockmap-ios + 5156804
4 libsystem_platform.dylib 0x0000000197ab593c _sigtramp + 52
5 stockmap-ios 0x00000001003fa7ec stockmap-ios + 3205100
Another thing make me upset is that, I can only reproduce this crash on production mode (after build to .ipa), but I'm not able to do this on development mode. That makes me crazy... As you know I lack dSYM so the crash log is to some extent useless.
For my code, What are the differences between this two modes?
env info:
os: ios 9
device: at least, happens on Ipad2, Iphone6, Iphone6s. unknow about others.
EDIT: I am going to repost a different version of this - I think I was focusing too hard on the fact it crashes in Testflight and not on the fact it crashes on iPhone but not iPad. (even from TF)
I'm having an annoying problem, and previous similar answers on SO aren't helping much.
I have a game (using Sprite Kit) which sometimes crash when a certain method finishes running. It does this 10% (or less) of the time when I run it on my iPhone 5s from Xcode, but if I upload to Testflight, it does it 100% of the time.
Xcode doesn't give me great debugging info, it shows a green breakpoint line in main.m on this line:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
and on the left panel it says this happens in:
Thread 1:
Queue: com.apple.spritekit.renderQueue 0
SKCRenderer::preprocessSpriteImp(std::__1::vector >&,
SKRenderQuadPool&, SKCSprite const*, _GLKMatrix4 const&, float,
unsigned int&, bool)const
and I see an EXC_BAD_ACCESS (code=EXC_I386_GPFLT) in this line:
0x1015bc663: movq 16(%rbx), %rcx
I will attach a pic actually of the surrounding stuff
I am bad at debugging and I don't know what to do. One notable thing is that this never happens in the iPad version. I'm very confused as to why it would happen sometimes but not always.
Because of derived data app might not crash while running from xcode. Few bad access are hidden if zombies are enabled.Its all about memory reference and some thing which legally is dead but actually exists at memory location can hide a legitimate bad access.
Try deleting derived data and disable zombies you will get same bad access from xcode as well.
I'm having trouble finding a bug in my app because it only presents itself after an adhoc installation. I have narrowed it down to [self.mapview removeOverlay:overlay]; and '[self.mapview addOverlay:overlay]. The exact same code with the exact same steps works just minutes before if I install and debug via Xcode (4.6.1). I'm not changing any other settings in between tests. I just Archive and distribute the app, or I press the Run button and it gets pushed to my iPad. One time it works, one time it fails.
Xcode->device = overlays can come and go as I want
Xcode->adhoc->server->device = complete app freeze when I try to remove a visible overlay or add one that is within the area the map can see right now
I've looked at the crash logs on the device and it always within [MKOverlayClusterView didAddSubview:] or [MKOverlayClusterView willRemoveSubview:]
Here's the main thread as shown in the crash log
0 libsystem_kernel.dylib 0x3c4ff27c __psynch_rw_wrlock + 24
1 libsystem_c.dylib 0x3c44fbd6 pthread_rwlock_wrlock + 334
2 MapKit 0x34fb321e -[MKOverlayClusterView willRemoveSubview:] + 50
3 UIKit 0x3614b2d2 __UIViewWillBeRemovedFromSuperview + 126
4 UIKit 0x35f93844 -[UIView(Hierarchy) removeFromSuperview] + 52
5 MapKit 0x34fae5b0 -[MKOverlayContainerView _removeOverlayView:forOverlay:coalesce:] + 24
6 MapKit 0x34fae118 -[MKOverlayContainerView removeOverlays:] + 240
It's worth noting that in both the add/remove variants the last top of the stack is the same so perhaps this is an issue with pthread_rwlock_wrlock meaning I've crossed threads at some point. I have tried to protect against this by using [self performSelectorOnMainThread:#selector(mainThreadRemoveOverlays:) withObject:#[overlay] waitUntilDone:YES]; but the crash keeps happening when the app is installed via the adhoc method and never happens when debugging via Xcode.
I had something similar problem. I was adding a map overlay to a map.
Worked fine when testing but not for Ad hoc deployment. My solution was that I had put the wrong case. I was using map.jpeg when the file name was actually Map.jpeg.
Map.jpeg != map.jpeg
As the map was working on test I just assumed that was the correct name. Took me a while to find out this was the problem. Not sure why my iPhone 5 or simulator did not pick this up.
Also it is good to Clean your project before deploying.
Hope this helps
First time I launch the app, everything seems to run fine. I'll hit the stop button, do some work and when I go to launch it again, it seems to crash before it can even load anything.
Press stop, hit Run again, and it works fine. Until I repeat the process.
This is where xcode is highlighting the error with "Thread 1:signal SIGABRT".
Obviously nothing useful here.
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([PokerAppDelegate class]));
}
}
The debug console shows nothing besides (lldb) (So I suppose its stopping, not crashing at this point)
So, when I perform a BT this is what I get:
(lldb) bt
* thread #1: tid = 0x1c03, 0x9a258a6a libsystem_kernel.dylib`__pthread_kill + 10, stop reason = signal SIGABRT
frame #0: 0x9a258a6a libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x99ea1b2f libsystem_c.dylib`pthread_kill + 101
frame #2: 0x04a7057b libsystem_sim_c.dylib`abort + 140
frame #3: 0x01dc0b4e GraphicsServices`GSRegisterPurpleNamedPort + 348
frame #4: 0x01dc069f GraphicsServices`_GSEventInitialize + 123
frame #5: 0x01dc0c1f GraphicsServices`GSEventInitialize + 36
frame #6: 0x000163f9 UIKit`UIApplicationMain + 600
frame #7: 0x00001d0d Guitar Chord Poker HD`main(argc=1, argv=0xbffff32c) + 141 at main.m:16
frame #8: 0x00001c35 Guitar Chord Poker HD`start + 53
(lldb)
Here's what I have done so far:
Performed a 'Clean'
I've reset the simulators and reset my computer
I've commented out all the code in the view controller, still crashes
I've commented out all the code in the app delegate, still crashes
BUT....I've run the app on a device outside of Xcode, and it seems
to work perfectly fine.
(EDIT) I've deleted/reinstalled xcode, and all content(Simulators, Docs) from the various cache folders (This stops xcode from automatically reinstalling the old ones after a new download). Still can't find where command line tools is kept though. Still crashes.
Despite all this, apps still crash every second/other launch.
Thing is I had no issues until the most recent Xcode update.
Could it be an Xcode bug?
(EDIT) I am also running the latest developer releases of OSX. Could that be interfering?
Seems to be a combination of OS X 10.8.4 and LLDB. As kenster says, switching to GDB makes the problem go away.
Edit:
It's caused by a race condition in the debug server (I hear).
Here's a fix if you want to keep using LLDB: Instead of clicking Run while the app is already running in the simulator, kill it in Xcode (⌘-.), say "I love Xcode" 5 times and Run it again (⌘-R). It won't crash, I tested it.
Fixed in Xcode 4.6.3.
I was having this issue as well. Take a look at this post. Xcode 4.6.2 app crashes on every second run
Basically change your debugger from LLDB to GDB. I can't believe this was due to LLDB being buggy.
Switching to GDB or rebooting device/host does not solve the issue in my environment.
However, modifying the Run target in the associated XCode scheme to no longer launch automatically but instead to "Wait for HelloWorld.app to launch" did.
Only drawback is that this implies to manually start the application on the device. The debugger will then get connected.