Chapter 18: "Sources" files not being recognized


I’m following through Chapter 18 and have come to the section on “internal, public, and open”. I’ve added the two Sources files, “Account.swift” and “Checking.swift”. I have changed all of the applicable class names, functions, etc. to include “public” as shown in the book. The main playground does not seem to recognize the files, nor does the Checking.swift code seem to recognize the Account.swift code. Any suggestions?

Doug Noll

1 Like

I went in and rebuilt the entire playground with sources, and now it works. I have no idea why it didn’t work the first time, but the issue is resolved.


I’m having the same problem. I deleted the playground, re-typed everything, and I’m back where I started: multiple errors in Checking.swift on every line in which something from Account.swift is referenced. The book says “all files in the Sources directory are part of one module,” but that certainly isn’t how Xcode (at least 12.4) sees it.

Any ideas from anyone?


P.S. The same errors show up when I open the Wenderlich-provided playground from the “final” folder.

1 Like

And more fun: Checking.swift can’t see the typealias and reports ““Cannot find type ‘Dollars’ in scope””. But if I copy it into Checking, I get “Invalid redeclaration of ‘Dollars’” Really? FROM WHERE?!?

1 Like

I am having the same problem!! What is happening? I tried another playground and create two files in the Sources folder and they seem to not be able to access each other’s public or open types!! Is it a Xcode bug??

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