Ch.18 "Cannot find type 'BasicAccount' in scope"

Hi all,

in this chapter, when I organized the code from playground to separate files, Xcode kept showing me this error saying it cannot find BasicAccount in scope, while the BasicAccount class and the Account protocol have been marked open and public (as you can see from pictures below).

The same problem persists even when I use the files provided in the Swift Apprentice Github repo!
Also, importantly, the code runs successfully despite the error message.

I’ve tried to figure it out but I am dumbfounded… is it some kind of bug from Xcode? I’ve tried rebuilding the file, restart Xcode and my computer, all of which did not work, please advise! Thanks a lot.

image

image

image

I was seeing similar errors on my code. What fixed it was to enable “Import App Type”. On the playground, under File Inspector, under Playground Settings, Enable Active Scheme, and Import App Types.
Example

1 Like

This topic was automatically closed after 166 days. New replies are no longer allowed.