- 新建一個test.swift后綴名的文件,寫下如下內(nèi)容
#!/usr/bin/env swift
for index in 1...10 {
print("Hello Swift\(index)")
}
- 然后到終端輸入
chmod +x ./test.swift 使腳本具有執(zhí)行權限
./test.swift 執(zhí)行腳本
#!/usr/bin/env swift
for index in 1...10 {
print("Hello Swift\(index)")
}