Xcode Autocomplete Frustrations

A year after it debuted, Xcode’s enhanced autocomplete features continue to struggle with overly liberal matches:

In this example, several of the matching text results display few commonalities with my search phrase . There’s really no reason that “fatale” should match CFDataGetLength(theData: CFData!).

It shouldn’t be hard to create heuristics that count the number of matched chunks, their distance from each other, to build a score related to whether the match is chunky (a good thing for keywords) and singular (another good thing for discerning developer intent).

Successful autocompletion promotes good matches and discards inappropriate ones. “upper” should score high on CFStringUppercase and low on CGScreenUpdateOperation and CSSMERR_TP_INVALID_CERTGROUP_POINTER.

That’s not the only problem with autocomplete. Image literal completion is a big problem. Xcode often prioritizes images over code APIs. When starting to type “picker”, Xcode should not suggest “picture-of-lovely-cat”. Here are some real world examples of this issue:

One developer told me that while typing in for closures, that eighty percent of the time, he gets a random autocompleted image literal instead of the keyword he’s shooting for:

Surely, this is an obvious place to introduce autocomplete preferences that allow you to exclude literals from the API list. The auto complete for image literals should act more like colors, offering an Image Literal entry point to a image picker instead of clogging the API name space:

It would certainly get rid of those inappropriate in matches.

Thanks Olivier Halligon, Andrew Campoli, and everyone else who gave me feedback and direction for this post.


  • […] Erica Sadun: […]

  • I wish you had started with a stronger example.

    I was reading this and to be honest, “fatale” had me looking for something like “femmeFatale”. (Sorry for the gender mention. And yeah, I wasn’t sure where you were going at that point.)

    Then you got into “chunks” and “distances” and… well, you almost lost me. Wasn’t seeing the point. Nothing you were talking about mattered – to me.

    Guess what? I’ve been in your spot – accused of being “too technical”. That’s when you mentioned my personal peeve – I accidentally named an asset image as “info”. And yeah, I’ve had to learn to type the damn thing out, type a space, no matter how (or when) I defined it.

    Maybe some of this can be things we can configure? Maybe some might be part of Xcode 9? (Speaking of peeves, maybe next month they’ll bring out macOS 11, iOS11, and – at least – Xcode 11?)

  • The autocomplete in Xcode is ridiculous. When I type:

    let x = 0x80

    it’s really infuriating that Xcode “auto completes” it thus:

    let x = kIOTimingIDVESA_1600x1200_80hz

  • AutoComplete ranks up there with sourcekitservice as the main obstacle to getting work done in Xcode.

    It’s bafflingly bad.

    Filling in function args is just crazy. If I have a function that takes, say, a String, why is AutoComplete offering to fill the arg with an Int or a CGFloat, prioritised above my actual String types?

    IMO, it’s time for core parts of Xcode to be open-sourced, ala Swift. We don’t want design-by-committee, but millions of iOS/Mac developers are at the mercy of a single tool, from a single company.

  • @David

    What about something like AppCode from JetBrains?

    I have never used AppCode myself, but I do use PHPStorm for any web-related languages (PHP, JS, HTML, CSS/Less…) and it is the best editor/IDE I’ve used for this (if not just a little bit clunky). It’s completions and smartness ranks right up there with Visual Studio (maybe even surpasses it in some areas).