Error while starting a playground: UNCAUGHT EXCEPTION (NSInvalidArgumentException)

Hey guys,

first of all - sorry for asking such a beginner question, but I didn't find a way to make my playgrounds running.

The thing is: I am currently going through a book App Development with Swift, where there are student playgrounds included, but what started happening is that is that I am unable to make these playgrounds to start. I didn't even touch the code since these are playgrounds that Apple is providing with given book. What happens is that when opening a given playground, my xcode opens and then suddenly closes. After a while a get this error:

UNCAUGHT EXCEPTION (NSInvalidArgumentException): -[__NSCFString replaceCharactersInRange:withString:]: nil argument

Has anyone dealt with this problem while running playgrounds?

Thank you very much.

What version of Xcode are you using?

Which specific playground shows this error?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
I am using version 12.0 (12A7209).

Almost all of them don't work. For example from Introduction to UIKIT it's Structures, Classes and Inheritance, Collections, Loops.

I am using version 12.0 (12A7209).

OK. I’m presuming this in on 10.15.6.

Almost all of them don't work.

Hmmm, I could do with something more specific. Here’s what I did:
  1. In Books I dowloaded the Xcode 10 version of the book.

  2. On page 5 there’s a “Download student materials” button. I clicked that.

  3. That opened Safari and downloaded a zip archive from this URL.

  4. I unpacked that.

  5. I open the playground Student Resources/2 - Introduction to UIKit/6 - Loops/lab/Lab - Loops.playground in Xcode.

  6. On page 1 there’s an exercise that starts with “Create a for-in loop that loops through each of the characters in the alphabet”. I did that (code below).

  7. I clicked the play button and my code ran and printed all the letters of the alphabet.

Please read through these steps and let me know how well they match up to what you’re doing.

Share and Enjoy

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



Code Block
let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for c in alphabet {
print(c)
}

The thing is that my xcode won't even open the code. What I do is:

  1. I am in Finder with all these student materials.

  2. I open the playground Student Resources/2 - Introduction to UIKit/6 - Loops/lab/Lab - Loops.playground.

  3. I can see on the top left that Xcode opens

  4. Xcode immediately closes and I am back in Finder

  5. Within 30 seconds or so I am getting given error

So I don't even have a chance to do anything with the code since Xcode closes immediately.

Do you think that another version of Xcode would help?

The thing is that my xcode won't even open the code.

Ah, that’s not good. Xcode is crashing trying to open your playground, whereas I previously thought that the code was crashing within your playground.

5. Within 30 seconds or so I am getting given error

That sounds like the crash report UI. If you run the Console app and select Crash Reports on the left, you should see a list of recent crash reports. Grab one that corresponds to your Xcode version and then post it here.

IMPORTANT Post it as a text attachment so as to avoid clogging up the timeline.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
So actually I think I've solved the problem: I downloaded Xcode 10.3 and now they are working flawlessly :)
Error while starting a playground: UNCAUGHT EXCEPTION (NSInvalidArgumentException)
 
 
Q