xcode playground keeps hanging/never ending while runtime or buildtime

Hi, I'm new to using xcode/playground.

theres an issue is that when I write even simplest few lines of codes , live view starts building/running,

I turned of the Live View but as you know it would still do it's thing as soon as you click or enter a new line ...

anyway the problem is that when the IDE recognize an error it wont clear sometimes, it's hard to explain and I couldn't find anyone with the same issue,

for example I write part of a for loop, or start declaring something or anything but I leave it incomplete to think or might even go somewhere else to change something ...

that's where I playground do it's thing and start build and run

then I go back and complete the code line and fix everything, but playground won't let go of the error and keeps on turning and won't go away until I quit and reopen it, then it would build and run in a few seconds perfectly.

it's really annoying having to reopen playground every 2 minutes


Xcode : Version 13.2.1

and I'm using a 2015 macbook pro 13 8gb corei5

MacBook Pro 13″, macOS 12.4

Posted on Jul 26, 2022 3:03 PM

Reply
Question marked as Top-ranking reply

Posted on Jul 26, 2022 6:51 PM

Here's the standalone macOS Playgrounds app: https://apps.apple.com/us/app/swift-playgrounds/id1496833156?mt=12


I've had reasonable success with that tool, and it's a handy way to learn Swift and to prototype Swift code.


I haven't tried running Xcode or Playgrounds with 8 GB, however. That 8 GB Core i5 somewhere between marginal and insufficient, for Xcode. You'll be paging memory in and out... a lot... when building any project of moderate to large size with Xcode.


You might do better with Playgrounds here, as that's not as big as Xcode.


Your Xcode is old. Xcode 13.4.1 is current.


Try upgrading Xcode to current, and also ensure you have maybe 10% of your total storage free (near-full storage gets slower), and shut off anything else active that'll want to compete for resources while you're using Xcode—add-on VPNs, add-on anti-malware apps, add-on cleaning apps, etc.

11 replies
Question marked as Top-ranking reply

Jul 26, 2022 6:51 PM in response to sepehringo

Here's the standalone macOS Playgrounds app: https://apps.apple.com/us/app/swift-playgrounds/id1496833156?mt=12


I've had reasonable success with that tool, and it's a handy way to learn Swift and to prototype Swift code.


I haven't tried running Xcode or Playgrounds with 8 GB, however. That 8 GB Core i5 somewhere between marginal and insufficient, for Xcode. You'll be paging memory in and out... a lot... when building any project of moderate to large size with Xcode.


You might do better with Playgrounds here, as that's not as big as Xcode.


Your Xcode is old. Xcode 13.4.1 is current.


Try upgrading Xcode to current, and also ensure you have maybe 10% of your total storage free (near-full storage gets slower), and shut off anything else active that'll want to compete for resources while you're using Xcode—add-on VPNs, add-on anti-malware apps, add-on cleaning apps, etc.

Aug 22, 2022 2:01 PM in response to sepehringo

To prevent the Playground from constantly compiling/updating: there's a little 'play button' style arrow or a square box in the lower left of the Playground window. Use that button to control the automatic run feature.


  • When the Playground is running, the square box shows; click the square to stop the Playground from running:


  • When the Playground is stopped, the 'play button' arrow shows; click the arrow to start the Playground running:


  • Click the tiny down-arrow next to the square or 'play button' style arrow to choose whether to allow the Playground to run automatically or to make it run ONLY when you WANT it to run (manually):



Once set to 'Manually Run', when you're ready for the Playground to run, click either:

  • the 'play button' arrow in the lower left, as shown above, or
  • the 'play button' arrow that appears on the current line when your cursor is in the line numbers area.

As a side note, using the arrow at the line number will only run the Playground's code from the beginning to the line with the arrow you clicked - helpful in testing small parts of code.



Jul 27, 2022 9:51 AM in response to sepehringo

sepehringo wrote:

so I'm not sure if it's my low low hardware , although it is pretty low,


So… You’d prefer your empirical data to be false, eh?


Your Mac is enough for macOS and mail.


There are a lot of folks around with an iMac 8 GB HDD Intel configuration, and that’s glacial, because the HDD is glacial and the paging activity is heavy. Here, that 8 GB memory configuration is only reasonably feasible by SSD-speed paging of memory out to main storage and back in again.


Xcode has a timer that fires periodically as you input text in the editor, and will recompile that source code in the editor view. This is part of error detection and reporting, and part of code completion, which is near prescient in its current implementation. It’s also resources-intensive. In the editor preferences, you might get a little more headroom with all that turned off.


Or use the Playgrounds app.


But that Mac is underpowered for Xcode.


Jul 26, 2022 3:23 PM in response to sepehringo

That's why they call it "playground". It's not for real work.


Sad to say, but your computer is just barely able to run Xcode itself. Then you add the simulator + Swift + Live Previews on top of that? On 8 GB with an Intel chip. I'm afraid Apple doesn't make any allowances for budgets.


For now, I recommend turning Live Previews off and keeping it off. Don't bother with Playground. When you just want to build, build against a build-only device. If you want to run, connect a real device and run it on hardware. Your computer will still be struggling with Xcode and Swift, but at least you'll have lifted half the burden.

Jul 29, 2022 5:03 AM in response to sepehringo

sepehringo wrote:

thanks! I guess there's no way around it then, other IDEs usually run well on low end for simple coding, so I thought it might be something else that's wrong

Xcode is more than just an IDE. You can use as an IDE and it works fine for that. I use Xcode to build websites in XML and XSL. Xcode is not too bad for developing Mac apps in Objective-C. But Swift is a ravenous beast that consumes CPU and RAM. And if you are developing anything other than a Mac app, Xcode is also running an entire virtual machine, with embedded operating system. "Playgrounds" is the most extreme mode that hides all the complexity from you.

Aug 22, 2022 2:10 PM in response to lisfolks

Also, I sometimes run Xcode on a mid-2010 MacBook Pro. Xcode Playgrounds has had this "Manually Run" feature all along, and that's what I've used to be able to do coding on that old machine. Sometimes it hangs for a bit waiting to start running or stop, but being able to stop it from compiling while I code is awesome!


Wishing you success in coding on your old machine till you can get that new one!

Jul 29, 2022 3:28 PM in response to sepehringo

As a completely different approach here, and which may or may not suffice here:


https://www.swift.org/blog/vscode-extension/


This uses Visual Studio Code to develop Swift code. How well that works, if it works, what limits it might have, I do not know.


I would suspect the Swift plugin for VSC is not suitable for submitting to the Apple app stores, but it'll let you learn about Swift, assuming your Mac has enough performance to run VSC.

Jul 26, 2022 10:42 PM in response to etresoft

I haven't even got to that part to make something on xcode !

It's weird because this happens on even on first 5-10 line of anything I write ! but as soon as I quit and reopen the playground project builds and run and clear those fake errors ...

so I'm not sure if it's my low low hardware , although it is pretty low,

but still shouldn't be a problem running a few lines ! should it ?!

Jul 29, 2022 12:28 AM in response to MrHoffman

thank you , everyone pointed that out so far, so I guess I'm gonna be needing to come around to +1000$ to be able to do swift

I already use the playground and it's the same problem, it wont clear the prior errors which were fixed and takes a never ending runtime to finish ( literally wrote like 20 lines and waited for like 2 hours to see if it will somehow find a way to clear those non existence errors.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

xcode playground keeps hanging/never ending while runtime or buildtime

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.