Post

Replies

Boosts

Views

Activity

Reply to Remove GIT Repository From Xcode
I found an old .git folder 2 levels up from where my project .git folder is (the path to my project in my post was made up). I'm not sure why it was there but I'm sure it isn't needed. I deleted it and now the Apple repository is gone, so my problem is solved. Not sure why Xcode was picking up something from a .git folder 2 levels up from my project.
Jun ’23
Reply to NavigationLink and .navigationDestination Hang and Infinite Loop
Here is the code using an ObservedObject. import SwiftUI import OSLog final class NavigationModel: ObservableObject { @Published var path = NavigationPath() { didSet { print("navigationModel.path.count: \(path.count)") } } } class Report: ObservableObject { @Published var title: String @Published var photo: UIImage? init(title: String, photo: UIImage? = UIImage(systemName: "z.circle")) { self.title = title self.photo = photo } } private let logger = Logger() struct ViewType: Identifiable, Hashable { let id: String } private var viewTypes = [ ViewType(id: "First View"), ] struct ContentView: View { @StateObject private var navigationModel = NavigationModel() @State var selection: Set<String> = [viewTypes[0].id] @StateObject var report = Report(title: "ContentView Report") var body: some View { NavigationSplitView { List(viewTypes, selection: $selection) { viewType in Text("\(viewType.id)") } } detail: { if let viewTitle = selection.first { switch viewTitle { case "First View": FirstView(report: report) default: Text("Invalid View") } } } .environmentObject(navigationModel) } } // FirstView struct FirstView: View { @EnvironmentObject var navigationModel: NavigationModel @ObservedObject var report: Report private enum NavigationLinkValueFirstView { case secondView } var body: some View { NavigationStack(path: $navigationModel.path) { NavigationLink(value: NavigationLinkValueFirstView.secondView) { let _ = logger.debug("FirstView NavigationLink") Text("Push Second View") } .navigationDestination(for: NavigationLinkValueFirstView.self) { value in let _ = logger.debug("FirstView navigationDestination") SecondView(report: report) } } .navigationTitle("First View") } } // SecondView struct SecondView: View { @State var showTheView = false @ObservedObject var report: Report private enum NavigationLinkValueSecondView { case firstView } var body: some View { NavigationLink(value: NavigationLinkValueSecondView.firstView) { let _ = logger.debug("SecondView NavigationLink") Text("Push New/Different Instantiation of First View") } .navigationDestination(for: NavigationLinkValueSecondView.self) { value in FirstView(report: report) let _ = logger.debug("SecondView navigationDestination") } .navigationTitle("Second View") } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’23
Reply to Xcode 14 Beta CloudKit Error
After looking into this some more, I found that if I use Xcode 14 Beta to create a new multi platform app as described above with just those 4 lines of code added, it will work fine on a device, but will crash when using a simulator. It still works fine under Xcode 13. I file bug report FB11354609.
Aug ’22