I'm working in SwiftUI App Lifecycle. I just updated Xcode and am getting a bunch of errors on an app that has been working fine on a slightly older version of Xcode...In AppKitOrUIKitViewControllerLifecycleEvent, I'm getting an error that says 'Missing argument for parameter 'rootView' in call'.
import Swift
import SwiftUI
#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
public enum AppKitOrUIKitViewControllerLifecycleEvent {
case didLoad
case willAppear
case didAppear
case willDisappear
case didDisappear
case layoutSubviews
}
struct _AppKitOrUIKitViewControllerLifecycleEventView<Content: View>: UIViewControllerRepresentable {
struct Callbacks {
var onDidLoad: ((UIViewController) -> Void)?
var onWillAppear: ((UIViewController) -> Void)?
var onDidAppear: ((UIViewController) -> Void)?
var onWillDisappear: ((UIViewController) -> Void)?
var onDidDisappear: ((UIViewController) -> Void)?
var onWillLayoutSubviews: ((UIViewController) -> Void)?
var onLayoutSubviews: ((UIViewController) -> Void)?
mutating func setCallback(
_ callback: ((UIViewController) -> Void)?,
for event: AppKitOrUIKitViewControllerLifecycleEvent
) {
switch event {
case .didLoad:
self.onDidLoad = callback
case .willAppear:
self.onWillAppear = callback
case .didAppear:
self.onDidAppear = callback
case .willDisappear:
self.onWillDisappear = callback
case .didDisappear:
self.onDidDisappear = callback
case .layoutSubviews:
self.onLayoutSubviews = callback
}
}
}
class UIViewControllerType: UIHostingController<Content> {
var callbacks: Callbacks?
override func viewDidLoad() {
super.viewDidLoad()
callbacks?.onDidLoad?(self)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
callbacks?.onWillAppear?(self)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
callbacks?.onDidAppear?(self)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
callbacks?.onWillDisappear?(self)
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
callbacks?.onDidDisappear?(self)
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
callbacks?.onWillLayoutSubviews?(self)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
callbacks?.onLayoutSubviews?(self)
}
}
func makeUIViewController(context: Context) -> UIViewControllerType {
UIViewControllerType() //root error view here
}
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {
}
}
#endif
In List++.swift, I'm getting Contextual closure type '(type1,type2) -> RowContent' expects 2 arguments, but 1 was used in closure body.
import Swift
import SwiftUI
extension List {
@available(watchOS, unavailable)
public init<Data: RandomAccessCollection, RowContent: View>(
_ data: Data,
selection: Binding<Set<SelectionValue>>,
@ViewBuilder rowContent: @escaping (Data.Element, _ isSelected: Bool) -> RowContent
) where Data.Element: Identifiable, Content == ForEach<Data, Data.Element.ID, HStack<RowContent>>, SelectionValue == Data.Element.ID {
self.init(data, selection: selection, rowContent: { element in //here this error appears
rowContent(element, selection.wrappedValue.contains(element.id))
})
}
@available(watchOS, unavailable)
public init<Data: RandomAccessCollection, RowContent: View>(
_ data: Data,
selection: Binding<Set<SelectionValue>>,
@ViewBuilder rowContent: @escaping (Data.Element, _ isSelected: Bool) -> RowContent
) where Data.Element: Identifiable, Content == ForEach<Data, Data.Element.ID, HStack<RowContent>>, SelectionValue == Data.Element {
self.init(data, selection: selection, rowContent: { element in //here the error also appears
rowContent(element, selection.wrappedValue.contains(element))
})
}
}
extension List where SelectionValue == Never {
@available(watchOS, unavailable)
public init<Data: MutableCollection & RandomAccessCollection, RowContent: View>(
_ data: Binding<Data>,
@ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent
) where Data.Element: Identifiable, Content == ForEach<AnyRandomAccessCollection<_IdentifiableElementOffsetPair<Data.Element, Data.Index>>, Data.Element.ID, RowContent> {
self.init {
ForEach(data) { (element: Binding<Data.Element>) -> RowContent in
rowContent(element)
}
}
}
}
On top of all this, I'm getting 'Command CompileSwift failed with a nonzero exit code' error. AND none of these files are even editable...no clue what to do. Any help much appreciated.