I created a project in Xcode, a console application, the goal here is a module. Therefore, I called the project test , and the target has the same name, so in the project the module itself also has the name test . Any global definition will be an implicit call to test. . Just as global Swift functions are an implicit Swift. call Swift. e.g. Swift.print("...") .
var a = 10; func foo() -> Int { let a = 20; Swift.print(test.a)
Output:
ten
So, you must add the module name in front of the variable in order to get global, not local, shading it.
source share