Closed zyg-github closed 9 years ago
这里 MyClass.swift 和 main.swift 是两个不同的输入文件,命令行 swiftc 后面直接跟的都是输入文件。
哦哦 我晕 是我错了 有劳了 还有个问题 ./MyClass.swift 为什么报错 难道我没有引入什么吗?
直接当脚本运行的话需要指定 swift 命令行位置,完整的应该是这样的
#!/usr/bin/env swift
print("hello")
// Terminal
> chmod 755 hello.swift
> ./hello.swift
// 输出:
hello
好的 谢谢 喵神
代码如下: class MyClass { let name = "XiaoMing" func hello() { print("Hello (name)") } } let object = MyClass() object.hello()
在xcode 是运行成功的 在命令行有错 错误: