Make environment for Swift Practice
I need to learn swift again, and of course XCode project is one of option to use Swift practice. But, I want to use simple env just try swift programming
I have some options to set up Swift Practice Env
- Playground
- Commandline and Text editor
- REPL
- Linux Docker with REPL
Playground
Playground is simple way to test swift program
This is XCode tool.
Commandline and Text editor
Create file and compile and run
hello.swift
import Foundation print("Hello")
Compile codes (with swiftc command)
swiftc hello.swift
Run execution file
./hello
If you want to run without compile
swift hello.swift
REPL
This is dialog base programming environment like Iron Python
To start REPL
swift
Welcome to Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15).
Type :help for assistance.
1>
Linux Docker with REPL
We can create isolated environment with Linux docker.
Swift supports Linux(Ubuntu), too. Docker image is provided by many people
This is an example (swift-docker)
docker pull swift docker run --security-opt seccomp=unconfined -it swift
You can use swift REPL on linux
コメント