Swift Playground does not show errors

I am starting Swift and using tutorials in Swift playgrounds for macOS.

So the sample code will be

var str = "Hello, playground" str str1 

I am not getting any red error information on page 1. Just a crash in the console

 Playground execution failed: error: MyPlayground.playground:1:1: error: use of unresolved identifier 'str1' str1 ^~~~ * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 * frame #0: 0x0000000102157360 com.apple.dt.Xcode.PlaygroundStub-macosx`executePlayground frame #1: 0x000000010215522a com.apple.dt.Xcode.PlaygroundStub-macosx`-[PlaygroundViewBridgeService execute] + 90 

If I correct the code, then the playground will be updated and show new data, it just will not report errors

How to stop Xcode from crashes and behave as documented?

Xcode Version 8.3 (8E162) macOS 10.12.4

I tried to delete all Xcode files (including the ones that it creates during build), and reinstall and use another user

+7
xcode swift-playground
source share
6 answers

In fact, a red mark β€œon the left side of the code” is displayed on the playground, as well as an automatic option for fixing the error, as well as regular projects.

enter image description here

I had the same problem as you (red marks did not show on the left). What decided for me:

  • Right-click on the error in the "Problem Navigator" (upper left panel)
  • In the menu> Open as> Quick view
  • Then run the same command again and "Open As> Playground Page"

I am on Xcode 8.3.2

Update: The same is true for Xcode 9.0

+15
source share

In the problem navigator, right-click the error -> open as quick view, then select it to open as a playground. This works for me.

+7
source share

File β†’ Playground Settings
check current news releases for source code
select show all problems radial button

Xcode was, as a matter of fact, as of 3/2017, showing inline errors on the playground, just as it happens in a project when editing a file. This behavior has changed in a recent update, although I do not see it documented. I assumed that this is a bug related to the latest patch, or maybe the default setting has been changed, which can be changed.

Edit: Actually, I just opened the playground that the preliminary patch created, and the errors show the built-in Show an example of work

Settings Settings required

+1
source share

What you see is the right behavior. If you want the red labels to be embedded in your code, use this project. Playgrounds do not show all errors, and if they show them, they show them, as you described, on the console, first with the same message that you would receive in red characters, and then with a rather meaningless crash log. (This is not an Xcode error; it is a special process for executing a playground.)

So this is what you see on the playground:

enter image description here

Here is what you see in the application project:

enter image description here

0
source share

Removing Derived Data and abandoning Xcode worked for me.

0
source share

Sometimes this function works more often than not, it is not. Xcode 8.3.3 was very difficult with this feature and made me avoid using playgrounds.

Here is the screen when it works in Xcode 9 Beta 6: enter image description here

Completing and reopening Xcode seems to help work again, but the tools seem to be rather confusing as I am experimenting with code.

When I mess up the code that causes the problems, the playgrounds stop trying to recompile, then I get an outdated feedback loop and I don't know if the code works or not.

... moments after I had a playground running in Xcode 9 Beta 6, it stopped working. Errors no longer appear on the line, so I recommend submitting more error reports to http://bugreport.apple.com

0
source share

All Articles