Comment

A few days ago Xcode 8.3 was released with Swift 3.1. You'll probably need to update some or all of the modules you've built so far as running swift build on any project with a Swift 3.0.x compiled library won't work. Notably, if you haven't been following the SwiftPM evolution, the folder where packages are stored has changed too. Instead of saving them at the root of your project's in the Packages directory, now the SwiftPM will keep a copy of all your dependencies in the .build folder. The Packages directory will still be used for packages you want to edit yourself, though.

News

All the changes in Swift 3.1 summarized in this article as well as changes to the Swift Package Manager and tools. Worth mentioning is that, similarly to Swift Packages build with Swift 3, some frameworks you may be using in iOS / macOS projects may need an update as they may not compile anymore in Xcode 8.3. I'm having this issue with one of the dependencies of the iOS project I'm on for my current client. It's exhausting 😩.

Swift

Using primitive types such as String or Int is a simple way of defining the data we need, especially in a strongly typed language like Swift. However, that often leads to misunderstanding and workarounds in the long-run. I had a first-hand experience of how using a typealias, protocol, enum, struct or class would have helped clarify the code's intentions as well as simplifying refactoring. Alex Curran does a great job at explaining how to use our favorite's language features better to improve our code.

If you missed this from iOS Dev Weekly last Friday, in this article, Soroush Khanlou explains in details how Sequence.enumerated is often misused to the different implementations that different collection types provide. He also offers a practical alternative with the zip function in Swift's Standard Library.

Code

As our apps will most likely run on Linux servers, it's critical that we ensure our tests run (and pass) on Linux as well as on Macs. A massive pain point when writing tests for our server-side Swift apps is remembering to add those tests to the allTests list or even adding a test case to the LinuxMain.swift file. The problem is that XCTest can find all our tests at run-time on macOS but not on Linux. Therefore we might not realize we're missing some. Ole Begemann with another great article this week writes about how to solve this problem with a few lines of code.

If you’re providing an API, chances are you’ve already experienced sudden increases in traffic that affect the quality of your service, potentially even leading to a service outage for all your users. However, by implementing a few API rate limit strategies, you can ensure your API is always available for everyone and decide when to scale it depending on its actual usage.

Another Vapor+Docker tutorial. This time on how to run your app on the Google Cloud Platform. Again, this tutorial uses Vapor, but any other server-side Swift framework would work just as well as the key technologies here are Swift, Docker and the Google Could Platform. If you fancy Kitura or Perfect, just swap the relevant bits with the implementation using your framework of choice and everything will work just fine.

The WebKit team explains what the Grid Layout is and how to use it. The Grid Layout is another display type that defines a Grid, of course, similar to what you may have already used with Bootstrap or any other CSS framework.

Working with CSS to produce similar results used to be a very hard task until recently. Bootstrap was one of the first frameworks to address the issue. Now we have built-in CSS layout systems that try to make our life easier. We can choose among so many options these days: the Grid Layout, Flexbox, Bootstrap grids and more!

Finally...

I thought I had screwed up something with my key bindings or that my inability to comment code was due to some problem with Xcode's broken syntax highlighting feature. Instead, this really works! Unbelievable!