Playground Sources (Files.swift)

Super excited to read this book!

If you’re like me and are already completely lost in chapter 1 at:

The Sources section of the playground contains Files.swift , which holds functions for saving and reading the sample data. Expand the Sources section, if it’s not already expanded, and open Files.swift .

and can’t find the Files.swift, in Xcode, click on View → Navigators → Show Navigator (or CMD-0 that’s zero).

Hi. I hope you enjoy the book.

Thanks for this clarification. I’ll see if I can add a note to the book.

Congrats on the new book. Here is a minor detail that might help others. I didn’t see the play button, but it was my own fault. The text clearly says to " Save Files.swift and return to the playground page." I didn’t return to the playground page, so I didn’t see the play button. User error.

I could not get pbpaste to work. It is possible that the single line in SampleData.json is too big at over 130000 characters. On my iMac, “getconf ARG_MAX” returns 1048576. What worked for me in Terminal was:

cd ~/Downloads
cat SampleData.json | json_pp > SampleData.pretty.json
cp SampleData.json SampleData.original.json
cp SampleData.pretty.json SampleData.json

Xcode 13.3.1, macOS 12.3.1, iMac 2017. Default shell in terminal: bash (because I have many years with it).

That’s strange. I’ve tested this on zsh and bash and they both work.
My getconf ARG_MAX also returns 1048576 so it can’t be that.

But your workaround will do the job, so thanks for posting it for anyone else who has the same problem.

After your response, I tracked this down and embarrassingly it is dumb user. I had done the Command-A to select the whole, original JSON file, but neglected the Command-C to put it in the clipboard. pbpaste does work for me if used correctly. Thanks for looking and sorry for wasting your time.

1 Like