Skip to content
Learn Netverks

Lesson

Step 5/36 14% through track

playground-workflow

Playground workflow

Last reviewed May 28, 2026 Content v20260528
Track mode
server_compiled
Means
Compiled runner
Reading
~2 min
Level
beginner

This lesson

This lesson teaches Playground workflow: the syntax, patterns, and safety habits you need before advancing in Swift.

Coroutines replace callback hell on Android and in Ktor—structured concurrency is interview-critical.

You will apply Playground workflow in contexts like: iPhone/iPad/Mac apps, server-side Swift (niche), and Apple toolchain projects.

Write Swift in main.swift with print(), click Run on server—the dev runner swiftc compiles and runs the binary (requires Swift toolchain, typically macOS; LEARNING_RUNNER_ENABLED=true). Also use print() only—UIKit and SwiftUI require Xcode projects, not this single-file sandbox.

At the start of the track—complete before lessons that assume you understand the compiled playground.

Get the most from each lesson’s compiled editor—the same habits transfer to Xcode playgrounds, CLI scripts, and CI running swift test.

Recommended workflow

  1. Read the concept section before editing code.
  2. Click Run to compile with swiftc and execute the binary.
  3. Use print() for debug output—avoid UIKit/SwiftUI imports in runnable snippets.
  4. Change one idea at a time; read compiler errors from top to bottom.

What the runner can and cannot do

  • Can — single-file main.swift with top-level code or @main, stdlib and Foundation
  • Needs local setup — Xcode projects, SwiftUI previews, iOS simulators, multi-target SPM apps

Compare with Kotlin, Go, and C# compiled tracks.

Important interview questions and answers

  1. Q: What prints to stdout in Swift lessons?
    A: print() from the Swift standard library—like println in Kotlin or fmt.Println in Go.
  2. Q: Why avoid UIKit in sandbox code?
    A: UIKit requires the iOS/macOS SDK and app lifecycle—not available in a single-file CLI compile.

Self-check

  1. What filename does the playground expect?
  2. What should you avoid importing in sandbox code?

Challenge

First compile and run

  1. Click Run with the default code.
  2. Confirm output appears in the terminal.
  3. Add a second print() with your name.

Done when: the terminal shows the default message and your custom line.

Challenge

First compile and run

  1. Click Run with default code.
  2. Confirm terminal output.
  3. Add a custom print().

Done when: terminal shows default and your custom line.

Interview prep

What runs code in the playground?

swiftc compiles main.swift into a binary executed on the macOS toolchain.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • swiftc errors?
  • print vs NSLog?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump