swift錯誤 Expressions are not allowed at the top level

```swift

... earlier we said top-level code isn’t allowed in most of your app’s source files. The exception is a special file named 「main.swift」, which behaves much like a playground file, but is built with your app’s source code. The 「main.swift」 file can contain top-level code, and the order-dependent rules apply as well. In effect, the first line of code to run in 「main.swift」 is implicitly defined as the main entrypoint for the program. This allows the minimal Swift program to be a single line — as long as that line is in 「main.swift」.app

```ui

緣由就是你把print等等表達式放到其餘文件去了。在main.swift這個文件中寫就沒問題code

知道怎麼改就能夠了。若是不知足的話,能夠看看上面這段官方代碼,寫得真好ci



文/把時間當作朋友(簡書做者) 原文連接:http://www.jianshu.com/p/6bc97afd9478 著做權歸做者全部,轉載請聯繫做者得到受權,並標註「簡書做者」。
相關文章
相關標籤/搜索