Ali Al-Abdullah

Swift/SwiftUI: My Practical Take

02 Feb 2024

Introduction

In the world of coding, my recent dive into Swift and SwiftUI has been all about keeping it simple and straightforward. Apple’s Swift language makes things smooth and simple.

Swift: Clean and Concise

Swift isn’t here to impress with fancy words. It’s a language that gets the job done without much fuss. My journey with Swift is about getting a grip on its basics, understanding its simplicity, and using it to build apps that just work. Views only have two different styles, Horizontical or Vertical.

It’s really this simple:


//  ContentView.swift
//  easycommits
//  Created by Ali Al Abdullah on 02/02/2024.

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundStyle(.tint)
            Text("Hello, world!")
        }
        .padding()
    }
}

#Preview {
    ContentView()
}

The following code shows a simple blank page that shows a globe and undeneath it, displays some text displaying ‘Hello, World’

Note: The Swift development enviroment is Xcode, Which is only available on MacOS

The devlopment enviroment is well laid out and easy to understand, this makes it great for users new to coding

Xcode GUI

Compatability

Swift stands out for its remarkable versatility, enabling the creation of cross-platform applications. Notably, apps written for iOS can effortlessly run on macOS, thanks to technologies like Catalyst.

This streamlined approach allows developers to use the same codebase for both platforms, enhancing efficiency and expanding their reach.

Swift’s ability to seamlessly transition applications across Apple devices underscores its pivotal role in fostering a unified development experience.

SF Symbols - Focus on the important things

Apple has a standarized set of icons and symbols that are very easily animated, resized and maniuplated. This allows you to focus on the important stuff like functionality. SF symbols has over 5,000 unique symbols.

Xcode GUI

symbols are organised by categories and also can also be animated in the SF symbols app so you can see what it will look like in the app. to insert this airtag logo in the code, we would use the line:

 Image(systemName: "airtag.radiowaves.forward.fill")

Conclusion

In conclusion, my exploration of Swift and SwiftUI has reaffirmed the power of simplicity in the coding world. Swift’s clean and concise syntax, exemplified in the provided code snippet, underscores its user-friendly nature, making it an ideal language for both beginners and experienced developers alike. The seamless compatibility between iOS and macOS further enhances its appeal, allowing for efficient cross-platform development. Additionally, the integration of SF Symbols adds another layer of simplicity, enabling developers to focus on functionality by easily incorporating standardized icons into their applications. With over 5,000 unique symbols and a well-organized library, SF Symbols streamlines the design process and contributes to a cohesive and visually appealing user interface. This practical take on Swift and SwiftUI, complemented by the versatility of SF Symbols, emphasizes the importance of straightforward approaches in creating effective and engaging software experiences within the Apple ecosystem.