Xcode Woes and Noes

Update: I did finally get stuff working after re-installing Xcode about a dozen times. And then it started acting up again. And then a few installs later it worked, etc. etc. Anyway, the gist at the bottom of this post works and I think it’s much more Swifty.

Screen Shot 2016-06-20 at 1.36.29 PM

So I’m watching 414. And I look at that code and I’m all “I could totally improve on that”. So I start, and once again, Xcode 8 blows up. I get the dreaded “Unable to determine compiler to use – the abstract compiler specification is missing from this Xcode installation” error, just like I do every time I try to create a new extension project or do anything particularly stressing to Xcode 8.

Screen Shot 2016-06-20 at 12.44.00 PM

Reinstalling Xcode 8 fixes everything until I attempt to open or create a project with an extension or I look at it wrong, because this issue isn’t limited to extensions.

You’d think this would be a really easy fix — edit a file somewhere or create a link or something — but I can’t figure out what to fix.  It’s particularly annoying because There’s so much in this original code that ticks me off (and no, that’s not my final code at the top of the list, that was just my first go at it, freehand).

Screen Shot 2016-06-20 at 1.40.47 PM

I can’t specify line numbers because the demonstrator didn’t enable them in Xcode (Preferences > Text Editing > Editing > Show > Line numbers). But here are a few key irritations:

  • Using an integer line index instead of enumerating and using key-value
  • Not guarding a conditional cast versus forced casting
  • Creating an array with () instead of a literal (: [Int] = [])
  • Building an Int-ish array instead of a [XCSourceTextRange] one from the start.
  • The newline update thing surely could have been done better.
  • Rule of Lily violation with “map”.
  • I hate “in” on the same line in closures.
  • The dictionary is ugly. And it’s declared in every run of the loop.

In any case, it’s unlikely I’ll get to play around with this because Xcode hates me. I thought I’d share and hope someone knows how to fix the dependency issue, and also it’s a kind of fun bad Swift snippet to fix, even if you can’t run the code and test it.

Let me know what you’d fix and if you get it running, share some code!

p.s. Update: Still no idea if this will work, but if you try it do let me know how it goes:

Comments are closed.