What is a Scope in swift playgrounds?

I am writing code in swift playgrounds iPad, and multiple things say "Cannot find 'xxx' in scope". What do I need to import into swift playgrounds? Do I need to do import SwiftUI. I'm not to sure.

If the code is in separate modules (files) they would need to be declared as public to be accessible in the playground file.

The same applies to initialisers, functions and variables as well.

The word scope is being used as defined here. Consider this Swift program:

func main() {
    print(blibble)
}

main()

Line 2 fails with Cannot find 'blibble' in scope, which is just a jargony way to say that it can’t find any definition for blibble.

And yes, I agree that this jargon is confusing for folks learning the language. I’ve filed a bug requesting that we change this error to be more accessible (r. 81264885).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

What is a Scope in swift playgrounds?
 
 
Q