I'm trying to get familiar with Xcode and Swift by writing a simple hello world program that has no UI.
When I create a new empty project in Xcode, there is no Target (scheme?), so I can't build and run. How can I create a target/scheme to satisfy the minimal build requirements? Steps to reproduce:
Alternatively, when I create a new App project it has UI that I can't seem to ignore. Where can I insert a function and print statement without getting a compile time error?
Steps to reproduce:
If all you need is just writing a simple swift program, then you can create a swift file as simple as below:
test.swift
print("hello world")
Then run swift test.swift in your terminal.
If you want to use Xcode, then you can create a simple command-line app by selection: Xcode -> File -> Project -> mac OS -> Command Line Tool.
Then Xcode will create a project with a swift file call main.swift which contains a simple print statement. Just build and run your project and check the console out.
If you just code without UI you can use Playground:
Xcode -> File -> New -> Playground
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With