How to build a Vapor Docker image with an environment variable?

I use Docker images when developing apps with Vapor. It’s a great way to run the code in the final deployment environment right from the start of the project. I use environment variables to direct the code execution and Docker provides a nice way to set them when building an…

Sharing data between an app extension and a containing app in macOS

I was developing a Safari App Extension and needed a way to share data between the containing app and the extension. I needed to pass the user settings, so the extension would behave correctly. The containing app does not have a direct access to the extension’s properties and vice versa….

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…