My experience with Swift programming

In 2019, I had a few ideas of apps, and I wanted to try creating my very first app to see if it’s difficult, especially for someone who’s not a developer. Since I’m an Apple user, I, obviously, thought about programming in Swift language, and I started my swift programming journey in late 2019.

At the beginning, I didn’t try to look for any online courses or materials to learn Swift programming. Instead, I tried to program by “patchworking” lines of codes related to the functionalities I wanted to implement into my app. I told myself that I have the algorithmic logic and a few notion of C language that I learned during my engineering school, so I should try to learn by practicing. Actually, I was just in hurry to create my first app :) So my patchwork was inspired by pieces of code that I found on forums like Stack Overflow and GitHub, and trainings that we can found on YouTube Channels and WebSites of Swift gurus like Paul Hudson.

In March 2020, following the Covid-19 pandemic, a lockdown has been decreed in France with an authorization to go out for an hour each day in a perimeter of 1 km around the lockdown location. After a few days, I wanted to move farer from home but still into the authorized perimeter and I didn’t find an easy way to visualize that perimeter cos the main means to do so, were through websites, and there was no app (at the beginning actually).

So I decided to create my own app to visualize that perimeter around my home, with the following functionalities :

  • Locate myself on a map ;
  • Enter my lockdown location (the home address for most cases) and draw a circle of 1 km around it ;
  • When the user goes beyond the perimeter, a warning notification is generated.
  1. In order to implement the Apple Maps (which is used for Apple Plans), we need to use the MapKit framework.
  2. At the app launch, an authorization is prompted to allow the user location with three alternatives. Obviously, if we want to benefit of the warning notification after going beyond the perimeter, we need to locate ourself.
  3. “Allow Once” allows only a one time location, “Allow while Using App” allows a location at each time the app is launched, but still not when the app is in background. Finally, “Don’t allow” is simply not allowing the location at all.

4. After authorizing geolocation, another authorization message is prompted to ask for allowing notification, in order to be notified when exceeding the perimeter.

  1. If the geolocation has been allowed, the user location will appear on a map as a blue round (here I configured the location coordinates as the Apple Park in Cupertino).
  2. At the top right, if the magnifying glass is touched, a field appear to enter the location address (we’ll talk about it later).
  3. Just below, the slider is used to set the radius of the perimeter, then the “ok” button has to be pushed to validate.
  4. At the bottom, a message shows the chosen radius .

5. When the magnifying glass is touched, a field appears to enter the location around which we want to draw a circle picturing the authorized perimeter.

6. If the user goes beyond the circle, a notification is generated.

Programming with Swift can be easy for someone who already have algorithmic and an object-oriented language basis. For this program, I used the UIKit framework, but I am currently programming with the more recent SwiftUI framework, which is more intuitive and bypass a lot of lines of code compared to UIKit. UIKit stays very well-documented, with a huge amount of trainings, and a lot of topics on forums like StackOverflow. At the same time I was developing this app, I was pursuing a training on Coursera which was pretty interesting but didn’t help me that much for this app since it didn’t tackle Mapkit framework.

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