How to set a port number for Vapor server on localhost

Vapor defaults to port 8080 on localhost. I couldn’t use the 8080, since that was reserved for another server on my MacBook Pro. Here’s how I set a different port number from the command line. swift run Run –hostname localhost –port 9000 This works with Vapor Framework 3.0.8 and Toolbox…

Using DispatchSemaphore to control asynchronous resources

A counting semaphore is a way of controlling access to a resource from multiple contexts. It can be also a solution for handling asynchronous methods in command line utilities. I was making a command line utility to access REST APIs recently. I needed a way to make sure that the…

How to make a progress bar for WKWebView

Progress bar is a nice way of showing users that our app is downloading content and things are progressing. The progress bar can be placed anywhere on the screen, but it is usually a thin line just under the navigation bar. We can create a progress bar programmatically and set…

Debugging Auto Layout: Unsatisfiable Contraints

When we work with auto layout we will hit an unsatisfiable constraint error at some point. The result is a view that looks somehow broken and there are a lot of text in the Xcode’s debugger window. The unsatisfiable constraint error means that there are some conflicting constraints and the…