Skip to main content

Swift

With daylight savings time being a few days old now for 2019 I thought I would put together a small tutorial on how to convert dates by timezone in Swift.  There are two approaches that I generally use when converting dates, the first is to use a Foundation's DateFormatter, and the second is to perform an Epoch calculation based upon your current timezone offset.  The advantage of using the DateFormatter approach is that dates can easily be displayed or evaluat

If there is one thing that I have learned in my career it's that network connectivity is not a binary state.  A network connection goes through many different transitions when setting up the connection, transmitting data, and closing down the connection.  In most cases, a client side mobile or desktop application can simply send the network request and if the client application is offline the request will immediately fail and the application can update the user accordingly (See article here).  However, the

One topic that I have seen come up a lot over the last couple of years is how to detect internet connectivity in an iOS or macOS application.  This is a topic that really interests me so I thought I would take some time and write a tutorial on how I and Apple recommend that client applications determine network connectivity.  To start, I thought I would provide some context on where this network connectivity model might be applicable.  The main use case is in a traditional client to server communication setting where a client is sending either a GET or POST request to a server, and the serv

What’s new in Swift is a news feed that focuses on the latest articles, trends, and stories happening around the Swift ecosystem that I find interesting.  All of the topics selected in this article have been cherry picked from either Github, Swift.org, or found the Swift Forums over the last few weeks and can range from topics covered in iOS, macOS, tvOS, watchOS, or in the Server Side community.

What’s new in Swift is a news feed that focuses on the latest articles, trends, and stories happening around the Swift ecosystem that I find interesting.  All of the topics selected in this article have been cherry picked from either Github, Swift.org, or found the Swift Forums over the last few weeks and can range from topics covered in iOS, macOS, tvOS, watchOS, or in the Server Side community.  This latest issue focuses on moving Swift NIO to Boring SSL, Alamofire 5 Beta, a unified Server Side Swift Logging API, and the SE-0235 - Result Tye Being added to the Standard Library.

What’s new in Swift is a news feed that focuses on the latest articles, trends, and stories happening around the Swift ecosystem that I find interesting.  All of the topics selected in this article have been cherry picked from either Github, Swift.org, or found the Swift Forums over the last few weeks and can range from topics covered in iOS, macOS, tvOS, watchOS, or in the Server Side community.  This latest issue focuses on SourceKit-LSP, adding Python 2 and 3 support to the Swift stdlib, a Swift by Sundell Podcast - Episode 38, and the WLAN project PureSwift. 

 

In years past Apple has announced their new operating systems, developer tools, and environments at WWDC and then in the fall final versions would be released to the entire developer base.  Today, it is a whole new world in that the Swift language has mostly diverged from this pattern and is released on a community driven time schedule.

In mid-December of 2017 a proposal went into review for the Swift language entitled, “SE-0192 – Non-Exhaustive Enums.”  In this proposal the Swift core team outlined a change to allow switch statements that consume enum types to be non-exhaustive or exhaustive, depending upon their needs.   The motivation behind this change was to allow for the easier additions to C based Enums in Apple or third party libraries without creating source breaking changes in projects downstream.

Writing unit testing is a cornerstone of software development.  When developing mobile or desktop applications, unit testing becomes even more critical, as there is often vital business logic that needs to be validated.  Have you ever found yourself wondering; what makes a great unit test in Swift? What key components give my application enough testing coverage to make sure that everything works and nothing regresses when new code is added to my project?  If you have asked yourself these questions then you are not alone.  In fact, that is why I wanted to write this tutorial.

When the Swift language went into development one of the goals it set out to achieve was to provide a better developer experience than the one that currently existed and to provide long term support against legacy C and Objective-C APIs.   Now that these goals have been achieved the Swift community is widening it's support to working with dynamic languages such as Python, Ruby, JavaScript, and Perl in Swift 4.2's language addition for Dynamic Member Lookups.  Providing support for these