No output on Xcode playground

Hi!

I have seen this question asked before, but so far, none of the answers were able to help me.

So here is the problem:

I'm an absolute beginner when it comes to programming and I'm trying to follow some tutorials online, but whenever I need to use Xcode playground, whatever code I type, it doesn't show up in the console or the debug area.

The most common answer on other threads was unchecking "Open using Rosetta", but it doesn't work in my case.

I'm using Xcode version 12.5.1 (12E507) on a MacBook Air M1, 12.0 Beta (21A5304g).

Is there anything else I can try before reinstalling or even factory reseting?

Thank you!

Answered by Graphics and Games Engineer in 686795022

Thank you for the info above, it was very helpful. I think what is happening is that the Xcode 12 LLDB debugger is not working properly on macOS 12. Swift Playgrounds must use the debugger while it executes your code, but since the debugger is not working, it can't execute the playground. There have been a lot of reports of LLDB issues with Xcode 12 on macOS 12. One bug report suggested that you should use Xcode 13 on macOS 12, so please try that and see if that resolves your issue.

Hi! Can you provide a sample playground that does not work as you expect? You shouldn't need to reinstall or factory reset anything.

Maybe you need to switch the mode of displaying messages in the console. It is located at the bottom of the Playground. Look at the screenshot below

Hi, thank you for the answers!

Can you provide a sample playground that does not work as you expect? 

None of the code works, even the simplest ones. Here's an example:

At the top, it says it's successful, but as you can see, no output in either console or debug area.

Maybe you need to switch the mode of displaying messages in the console.

I tried that too, but still no output.

I also forgot to mention in my first post that Swift Playgrounds (the learning program) works just fine, as in, it shows the output in the console.

Again, thank you!

-- Deleted --

Could you add the line assert(false) to your playground? If the playground is executing, you should see an error. Also, try removing the import UIKit line, just in case there is some issue with that. If those don't work, I might have you file a bug report on Feedback Assistant since I didn't see any similar bug reports about this.

Still nothing :/

I will file the bug report asap.

In the meantime, I'll also try to reinstall the whole Xcode.

Thanks. Since you are not hitting the assert that probably means that your playground is never running, which is why there is no output. Can you try switching to manual mode by pressing and holding on the play button? Also can you try running this through the Xcode 13 beta?

Tried manual multiple times, no luck.

Before I download Xcode 13 beta, there is one more thing I should mention. Whenever I try to run a code, I get error: attach by pid '3733' failed -- lost connection and when I click the details, it shows me this

Details

Could not attach to pid : “3819”

Domain: IDEDebugSessionErrorDomain

Code: 3

Failure Reason: lost connection

User Info: {

    DVTRadarComponentKey = 855031;

    RawUnderlyingErrorMessage = "lost connection";

}

--

System Information

macOS Version 12.0 (Build 21A5304g)

Xcode 12.5.1 (18212) (Build 12E507)

Timestamp: 2021-09-04T02:17:35+02:00

The number after "pid" ALWAYS changes whenever I run it again and again and it ALWAYS goes up.

Maybe all of this has to do something with the Playground bug.

Edit: Forgot to mention this applies to Xcode projects, not Xcode playground

Accepted Answer

Thank you for the info above, it was very helpful. I think what is happening is that the Xcode 12 LLDB debugger is not working properly on macOS 12. Swift Playgrounds must use the debugger while it executes your code, but since the debugger is not working, it can't execute the playground. There have been a lot of reports of LLDB issues with Xcode 12 on macOS 12. One bug report suggested that you should use Xcode 13 on macOS 12, so please try that and see if that resolves your issue.

I just installed Xcode beta 13, and I think it fixed it. Playground shows output and projects don't show "attach by pid" error when ran.

Thank you so much!

I have encountered same problem in Xcode 14.0.1

The same issue on Xcode 14.1

Using an macbook from 2017 (Intel based) in which I did a factory restore then installed up to Ventura, then installed xcode yesterday

XCode 14.1 Playground Ventura 13 Only apps not included with OS are chrome and xcode.

On Manual mode. Intermittently works and doesn't. Wasnt working the first time I started, suddenly started working. Was ok for 30 or so min then stopped. Then laptop crashed.

On restart, same issue. Switched to from automatic and back to manual and eventually started to work on its own again.

I have a same issue on MacBook Air (M1, 2020) MacOS Monterey Version 12.6, Xcode Version 14.2 (14C18). Turning Rosetta on/off doesn't help. Please suggest a solution

No output on Xcode playground
 
 
Q