I don't like XCode

In my previous article I explained how I got from Android to iOS. Most of the experience was positive, but the worst part is worth an article on his own: XCode.

Working with XCode can be really frustrating being used to IntelliJ / Android Studio / Any decent code editor. I'll try to be as factual as possible.

  • Being forced to drag & drop between Interface Builder and code on a 15" Macbook Pro is... problematic. You can close most of the navigators / inspectors / etc... but then you need to open them again. So I usually ended up like that:

  • No refactoring for Swift. You can't rename a method, a field or anything. You have to do it manually, so usually it's just renaming something, then compile and fix compilation issues, then run and see if anything else is broken (most of the time if the Storyboard had a reference to it).

  • The directory structure in XCode is not tied to the file system directory structure. So, when you create a folder from XCode (called "group"), you need to manually create a folder with the same name in the file system, and remember to add all subfiles to it. If you forget to add a new file in the correct directory, you need to manually move the file (using Finder), then delete the file in XCode and reimport it. Or you can just give up and leave every file at the root of the project, but then browsing it from the outside — like Github — would be quite a mess.

  • Sometimes you can't comment some code out, for no reason.

  • There's no way to re-indent the whole file without losing the current cursor position. You have to do select all and re-indent (⌘A ^I), then click where you were before the re-position the cursor.

  • Pressing Tab with multiple lines selected replace these lines with a tab instead of indenting them. Note that you can change this default behavior so that Tab always acts like ^I (re-indent), which is okay I guess.

  • No shortcuts to delete / duplicate a line. I really missed these.

  • No code formatting, XCode can only indent code, there are no built-in ways to apply code style rules to it.

  • No way to code "by intention". IntelliJ has a lot of very smart quick fixes, and it became kind of a new way of coding, faster than anything else I've ever seen. For example, in a method you try to call a method that doesn't exists, like:

class MyClass {

    func anyMethod() {
         let a = 1
         showSomething(a) // Cursor is here
    }

}

showSomething doesn't exist so there's an error, but then your press Alt+Enter to open the intention actions popup, then Enter again to select the first choice: "Generate method showSomething", and you end up like this:

class MyClass {

    func anyMethod() {
         let a = 1
         showSomething(a)
    }

    func showSomething(_ a: Int) {
         // Cursor is now here
    }

}

And that works for almost anything: declare a field, a variable, implement a protocol, generate missing methods from protocol, etc…

Conclusion

XCode 8 is probably already a big improvement over the previous versions. It's almost stable — still 1 or 2 crashes a day —, but the code edition is still a pain. I thought I'd give it a chance, but it's years behind what JetBrains does, there's no way it can catch up fast enough. Hopefully JetBrains supports Swift through AppCode now, that's worth a shot!

Thank you for reading, I'm still new to XCode so feel free to prove me wrong if I missed some features, share your own tips or add something to the list!

comments powered by Disqus