Xcode 13.2.1 SwiftUI Preview Issues

My System

  • 15” MacBook Pro late 2018 (Intel)
  • macOS Monterey 12.1
  • Xcode 13.2.1 December 17, 2021
  • Command Line Tools for Xcode 13.2 December 13, 2021

Summary

Live Preview

  • The hardware keyboard does not work.
  • Tapping a TextField invokes an invisible keyboard.
  • Running on simulators from Preview fails.
  • Running on real devices from Preview works.

Except for these issues everything is working: Local packages and GitHub packages. Running schemes on simulators and real devices. XCTest UI tests on simulators and real devices.

Update Timeline

Dec 13, Using the App Store original 13.2 (13C90), no issues.

Dec 14, Working on a UIKit based project - "This build requires an update”. The update did not affect the project. Switched to a SwiftUI based project and this error occurred: "Missing Package Description Module" [https://developer.apple.com/forums/thread/696504]

Updated to Developer 13.2 (13C90) Everything is working except these issues persist.

Dec 17, Updated to Developer Xcode 13.2.1 and this error occurred: "SwiftUI Previews Crash (i.e. cannot compile preview)" [https://developer.apple.com/forums/thread/696908]

Executed this command and it fixed the issue (thanks forums!):

rm -rf "$(getconf DARWIN_USER_CACHE_DIR)clang/ModuleCache"

Everything is working except these issues persist.


Demonstration SwiftUI App

//
//  ContentView.swift
//  TestKB
//  Target: iOS 15.2, iPhone, Portrait
import SwiftUI
let usage =
"""
Xcode 13.2.1 (13C100) Preview Test
The hardware keyboard does not work.
Tap the TextField to invoke the
invisible keyboard.
Blindly tap in the invisible keyboard
below the TextField to enter text.
"""
struct ContentView: View {
    @State private var input = ""
    var body: some View {
        VStack(alignment: .leading) {
            Spacer()
            Text(usage)
            TextField("TextField:", text: $input)
                .autocapitalization(.none)
                .disableAutocorrection(true)
                .border(Color.blue, width: 2)
        }
        .textFieldStyle(.roundedBorder)
        .padding(5)
    }
}
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        Group {
            ContentView()
        }
    }
}
//
//  TestKBUITests.swift
//  TestKBUITests
//
import XCTest
class TestKBUITests: XCTestCase {
    override func setUpWithError() throws {
        continueAfterFailure = false
    }
    func testExample() throws {
        let app = XCUIApplication()
        app.launch()
        XCTAssertTrue(app.textFields["TextField:"].exists)
        let tf = app.textFields["TextField:"]
        tf.tap()
        tf.typeText("Buona giornata!")
        XCTAssertEqual(tf.value as? String, "Buona giornata!")
    }
}

Running On Simulator Devices From Preview Fails

Sorry but I cannot upload the previews-diagnostics-20220108-214936.zip file because the file is blacked out in the Add File/Finder dialog.

Running On Real Devices From Preview Succeed

Live Previews Do Not Work

Running the scheme on simulators and real devices works.

Submitted the report to Apple (FB9849434).

Any updates on this?

Xcode 13.2.1 SwiftUI Preview Issues
 
 
Q