SWIFT DEVELOPER GUIDE

What can run in an online Swift playground?

Understand the boundary between Swift, Foundation, and Apple’s UI frameworks.

Start with the language

Loops, optionals, collections, structs, enums, and many other language features work in a command-line program. They are good candidates for small browser experiments. Choose an available compiler version rather than assuming an old example still uses the same language rules.

Foundation is cross-platform, with differences

Foundation provides common data and utility APIs. Availability and behavior can vary by platform and toolchain. On Linux, some networking APIs need FoundationNetworking. Use conditional imports for examples intended to run on more than one platform.

UI frameworks need their platform

UIKit, AppKit, and SwiftUI are Apple-platform frameworks. A Linux compiler cannot provide an iPhone simulator or preview a SwiftUI view. Use Xcode or an appropriate Apple environment for those tasks.

Know the sandbox

The compiler runs outside your computer. Its working directory and temporary files belong to the execution sandbox. Network access and run time may be limited. Download the source when an experiment needs local files or platform-specific APIs.

Try a Swift example