Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift Playground not showing errors

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

So example code would be

var str = "Hello, playground"
str
str1

I do not get any red error information on the str 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 does refresh and show new data it is just not reporting the errors

How do I stop Xcode from crashing and behave as documented?

Xcode Version 8.3 (8E162) macOS 10.12.4

I've tried deleting all Xcode files (including the ones that it creates during a build) and reinstalling and using a different user

like image 747
mmmmmm Avatar asked Apr 05 '17 21:04

mmmmmm


People also ask

How do I see errors in Xcode?

2) Go to: xCode preferences > General > "Issue Navigator Detail" > now boost the dropdown to 10 lines. Now you can see the whole message in the issue navigator! Save this answer. Show activity on this post.

How do I debug in Xcode playground?

Xcode also gives you an interactive LLDB debugger window, where you can type commands to query values and run methods. If it's visible, you'll see “(lldb)” in the bottom of your Xcode window. If you don't see that, go to View > Debug Area > Activate Console, at which point focus will move to the LLDB window.

Does Xcode still have playground?

You can use playgrounds in Xcode to quickly write some Swift code, experiment with new Swift syntax, or work on your Swift algorithms skills. Most of all, playgrounds in Xcode are a great way to learn Swift programming. In this tutorial, you'll learn how to get started with playgrounds in Xcode.


3 Answers

Actually a Playground does show the "red mark error on the left side of code" and there's also an automatic option to fix the error, just as regular Projects.

enter image description here

I had the same problem as you (red marks wasn't showing up on the left). What solved for me:

  1. Right click the error on Issue Navigator (top left panel)
  2. On the Menu > Open As > Quick Look
  3. Then do the same command again and Open As > Playground Page

I'm on Xcode 8.3.2

Update: Same is valid for Xcode 9.0

like image 78
Marcos Reboucas Avatar answered Sep 23 '22 06:09

Marcos Reboucas


In the issue navigator, right click the error -> open as quick look, then select it back to open as playground. It works for me.

like image 34
SuperBatman Avatar answered Sep 21 '22 06:09

SuperBatman


File -> Playground Settings
check show live issues for source code
select show all issues radial button

Xcode was, in fact, as of 3/2017 showing errors inline in the playground, just as it does in a project when editing a file. This behavior changed in a recent update, though I don't see it documented. I assumed it was a bug introduced with the latest patch, or perhaps a default setting was changed that can be changed back.

Edit: In fact, I just opened a playground I created pre-patch, and errors show inline Show example of it working

Settings are Settings needed

like image 27
froggomad Avatar answered Sep 21 '22 06:09

froggomad