What’s New in Xcode 11.4?

Swift 5.2, Clang Compiler 11.0.3, and more

Dmytro Pylypenko
Mar 24 · 3 min read
Xcode 11.4
Xcode 11.4

Apple continuously tries and makes our favourite tool for developing applications for iOS/macOS/watchOS/etc. even better.

They announced interesting new features, which I’ll describe briefly. In my opinion, they’re actually very important.


Clang Compiler (11.0.3)

If your framework uses any third-party framework dependencies, the compiler displays the warning -Watimport-in-framework-header by default in the event of a framework importing a third-party dependency.


Debugging

  • The view debugger shows UILayoutGuide and its referencing constraints

Simulator

  • Install certificates for trusted connections via drag and drop or terminal:
    xcrun simctl keychain booted add-root-cert my-selfsigned.cer

Swift (5.2)

  • Updated compiler supports declaring default values in higher-order functions from first-class functions
func foo(x: Int) {
func bar(y: Int = x) { print(y) }
bar(y: 42)
bar() // 21
}
foo(x: 21)
  • Structs (possible classes and enums) support the callAsFunction feature.
    The idea is to use a reference like it’s a function. It’s good to know that callAsFunction isn’t limited and behaves like a typical function. It supports closures, mutating keywords, and can throw and rethrows. And it’s possible to declare different callAsFunctions.
struct Escaper {
let strategy: EscapeStrategy
let archiver: Archiver
func callAsFunction(_ value: String) -> String {
archiver.exec(strategy.encode(value))
}
}
let escape = Escaper(strategy: strategyA, archiver: gzipArchiver)
escape('Occupy Mars 🚀')
  • Subscript supports default parameters
struct MatrixArea {
subscript(x: Int, y: Int = 0) -> Int {
...
}
}
matrix[10] // 100
matrix[2, 2] // 16
  • New strategy of code diagnostics — thus, better compile-time errors explanations. See examples here.

Testing

The XCTest class supports throwable functions to setUp(), tearDown(),
setUpWithError(), and tearDownWithError(). If an error is thrown, the method is marked as failed but with usage of XCTSkip API — skipped.

An interesting feature is it’s possible to skip the test code flow based on conditions:

func testLocation() throws {
try XCTSkipUnless(Permissions.locationGranted) // skip test

...
switch location.intersects(dimension: dimension) {
case .one: try XCTSkip() // skip test
case .two: try testJump()
case .three: try testLookingAfterCorner()
@unknown default: fatalError()
}
}

Summary

I enjoy that with each new update to Xcode and its related tools, it gets easier and more comfortable to develop applications and projects. I hope this year will be bring more interesting things.

More detailed information is here:

Better Programming

Advice for programmers.

Dmytro Pylypenko

Written by

Sociologist & Software Engineer. iOS Tech Lead @ ZINIO

Better Programming

Advice for programmers.

More From Medium

More from Better Programming

More from Better Programming

More from Better Programming

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade