Some new features in Xcode 14.3

Xcode 14.3 includes Swift 5.8 and SDKs for iOS 16.4, iPadOS 16.4, tvOS 16.4, watchOS 9.4, and macOS Ventura 13.3. The Xcode 14.3 release supports on-device debugging in iOS 11 and later, tvOS 11 and later, and watchOS 4 and later. Xcode 14.3 requires a Mac running macOS Ventura 13.0 or later.

Xcode 14.3 Release Notes

SwiftUI Previews now supports print()

Implicit self now permitted after unwrapping self

import UIKit

struct API {
    func fetch(completion: @escaping (() -> Void)) { completion() }
}

final class ViewController: UIViewController {
    private let api = API()

    override func viewDidLoad() {
        super.viewDidLoad()
        fetchData()
    }

    func fetchData() {
        api.fetch { [weak self] in
            guard let self else { return }
            loadUI() // implicitly refers to `self.loadUI()`
        }
    }

    func loadUI() {}
}

let viewcontroller = ViewController()
viewcontroller.loadViewIfNeeded()

New modifiers on .sheet

import SwiftUI

struct BottomSheet: View {
    var body: some View {
        Text("Bottom Sheet")
    }
}

struct ContentView: View {
    @State private var isBottomSheetPresented = false

    var body: some View {
        Button(action: {
            isBottomSheetPresented.toggle()
        }) {
            Text("Present Sheet")
        }
        .sheet(isPresented: $isBottomSheetPresented) {
            BottomSheet()
                .presentationDetents([
                    .fraction(0.3),
                    .height(200),
                    .medium,
                    .large
                ])
                // 1
                // To let people interact with the content behind a sheet
                .presentationBackgroundInteraction( // only available in iOS 16.4 or newer
                    .enabled(upThrough: .fraction(0.3))
                )
                // 2
                // Give your sheet a translucent background
                .presentationBackground(.thinMaterial)
                // 3
                // New feature in iOS 16.4 corner radius on the sheet
                .presentationCornerRadius(24)
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Resources

Apple docs: Xcode 14.3 Release Notes

Apple docs: iOS 16.4 Release Notes

Swift.org: Swift 5.8 Released!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s