Curly brackets in a comment crashes XCode 10.0

Hello, everybody,


I've been using XCode (Version 10.0 (10A255) to learn to program in Swift version 4.2 (swiftlang-1000.11.37.1 clang-1000.11.45.1). I've been creating macOS playgrounds to experiment with code, using a lot of commenting to keep track of what I'm doing.


The problem is with curly brackets in commented code. If I paste code in that contains curly brackets and then comment out the lines ('//') Xcode crashes. If I enter code with a curly bracket after // (or /* */), XCode crashes.


I did a search here and elsewhere in regards to this problem, but the search returned nothing relevant. If anyone is interested, I can attach various crash reports.


Thanks in advance,

Grey

Replies

Under normal circumstances I’d suggest filing a bug report about this but that’s probably not worth your time because we’ve very unlikely to ship an update to Xcode 10. That restricts us to just finding you a workaround (other than to not do what you’re doing).

I’m presuming that you’re on an old machine that can’t upgrade to Xcode 11. Is that right?

What macOS release are you running on?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hello, Quinn,


Thanks for the reply. Yes, you guessed it: I am on an older machine (mid-2010) maxed out at High Sierra (10.13.6 (17G13035)), hence XCode 10.0/Swift 4.2.


To illustrate better what's going on, here's an example:

for (keyHolder, valueHolder) in dictionaryName {
    // Body of loop
}

I can paste that into my playground but when I comment out the first line, crash!


Another example: I can type in the following...

// for (keyHolder, valueHolder) in dictionaryName

...but when I add an opening '{', crash!


I'd like to attach the crash reports and possibly the last playground I created, which strangely enough contains no code but only comments! When I try to open that, XCode immediately crashes. Can I attach files here?


Any ideas/workarounds on your part are welcome! Thanks.

Yowsers! It took me a while to get Xcode 10 installed but, once I did, I was able to reproduce the crash. Specifically:

  1. I created a playground from the macOS > Blank template.

  2. I selected all and pressed Delete to delete the default text.

  3. I pasted in the following:

    let dictionaryName: [String: String] = [:]
    // for (keyHolder, valueHolder) in dictionaryName

    .

  4. I pressed Delete to get the insertion point back on to line 2.

  5. I pressed

    {
    and it crashed.

Looking at the crash report it’s dying in SourceKit. There’s really not much that you can do about that. While SourceKit is reasonably stable now, for a long time it generated a lot of crashes )-:

I was testing with Xcode 10.0. Have you tried 10.1? That should be compatible with 10.13.6.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Wow. That's certainly going above and beyond the call of duty, installing an old version just to verify a crash!


Regarding "upgrading" to 10.1, I'd certainly consider it but AppStore says I'm at the "latest" version (10.0). I wonder if the curly bracket bug is fixed in that point release...?


In any case, my workaround is this...

// for i in example 'curlyopen'
     // my code
// 'curlyclose'


No problems so far! 😆 Quinn, thanks for all your help! I guess there's not really a whole lot that can be done to resolve this odd bug.

I'd certainly consider it but AppStore says I'm at the "latest" version (10.0).

You can download old versions from the Downloads area on the developer web site. Click More (at the top right) get to the archive.

I’m pretty sure that 10.1 will run on 10.13.6 but I don’t have time to test it myself today (-:

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Quinn,

I dl'd and installed XCode v10.1 from your link, and so far so good! It appears this bug has been quashed. Thanks for all your help!