Write a Network Layer in Swift

Photo by C Dustin


  • it would be easier if you knew something about type erasure
  • To install the network manager to which this refers, you will need to know something about Swift Package Manager


Type Erasure: Removing type information by wrapping a type

The public API

There are two entry points for this network manager — both AnyNetworkManager and NetworkManager are publicly accessible. Not only that - there is a MockNetworkManager that is publically avaliable for testing.

Using tests

In order to test the network manager, the package can be downloaded and ⌘-U will run the tests.


Want to look at the whole thing? network manager has the whole thing, tests an all.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store