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