Xcode playground gets stuck on 'Running playground' or 'Launching simulator' and won't run the code, what to do?

前端 未结 22 716
情歌与酒
情歌与酒 2020-12-22 16:03

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

相关标签:
22条回答
  • 2020-12-22 16:05

    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.

    0 讨论(0)
  • 2020-12-22 16:05

    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

    0 讨论(0)
  • I'm using Xcode 10.2 and am getting the same issue. So generally just use Online Swift Playground

    This serves my purposes! :-)

    0 讨论(0)
  • 2020-12-22 16:10

    Also happens, like in my case, when you've defined a function, but have forgotten to call it?

    0 讨论(0)
  • 2020-12-22 16:12

    You can switch to manual processing. It worked for me.

    0 讨论(0)
  • 2020-12-22 16:12

    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.

    0 讨论(0)
提交回复
热议问题