Provide views, controls, and layout structures for declaring your app's user interface using SwiftUI.

SwiftUI Documentation

Posts under SwiftUI tag

2,346 Posts
Sort by:
Post not yet marked as solved
0 Replies
5 Views
I have a driving tracking app I'm working on that properly starts tracking and logging location when the app is in the foreground or background. I use a buffer/queue to keep recent locations so when a trip ramps up to driving speed I can record that to work back to the start location just before the trip starts. This works great, however, in background mode when the user does not have the app open it will record locations but not until a significant location change is detected. The buffering I do is lost and the location only starts tracking several hundred yards or more after the trip has started. Does anyone have any suggestions or strategies to handle this chicken and the egg scenario?
Posted Last updated
.
Post not yet marked as solved
0 Replies
20 Views
hi I have been using WKWebView embedded in a UIViewRepresentable for displaying inside a SwiftUI View hierarchy, but when I try the same code on 17,5 beta (simulator) the code fails. In fact, the code runs (no exceptions raised or anything) but the web view does not render. In the console logs I see: Warning: -[BETextInput attributedMarkedText] is unimplemented Error launching process, description 'The operation couldn’t be completed. (OSStatus error -10814.)', reason '' The code I am using to present the view is: struct MyWebView: UIViewRepresentable { let content: String func makeUIView(context: Context) -> WKWebView { // Javascript that disables pinch-to-zoom by inserting the HTML viewport meta tag into <head> let source: String = """ var meta = document.createElement('meta'); meta.name = 'viewport'; meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'; var style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = '*:focus{outline:none}body{margin:0;padding:0}'; var head = document.getElementsByTagName('head')[0]; head.appendChild(meta); head.appendChild(style); """ let script: WKUserScript = WKUserScript(source: source, injectionTime: .atDocumentEnd, forMainFrameOnly: true) let userContentController: WKUserContentController = WKUserContentController() let conf = WKWebViewConfiguration() conf.userContentController = userContentController userContentController.addUserScript(script) let webView = WKWebView(frame: CGRect.zero /*CGRect(x: 0, y: 0, width: 1000, height: 1000)*/, configuration: conf) webView.isOpaque = false webView.backgroundColor = UIColor.clear webView.scrollView.backgroundColor = UIColor.clear webView.scrollView.isScrollEnabled = false webView.scrollView.isMultipleTouchEnabled = false if #available(iOS 16.4, *) { webView.isInspectable = true } return webView } func updateUIView(_ webView: WKWebView, context: Context) { webView.loadHTMLString(content, baseURL: nil) } } This has been working for ages and ages (back to at least ios 15) - something changed. Maybe it is just a problem with the beta 17.5 release?
Posted Last updated
.
Post not yet marked as solved
0 Replies
19 Views
Hello everyone,I am a student who is working on my final project of my college.I do not get an official development account since I do not need to put my app on AppStore. In my project,I need to use the camera of iOS device, and I know I need to add NSCameraUsageDesciption in Info.plist.However, as I add the description in my Info and build my project, it failed and says"Provisioning profile "iOS Team Provisioning Profile: " doesn't include the NSCameraUsageDescription and NSPhotoLibraryUsageDescription entitlements." I also notice that in the Info.plist file, when I change the property type to entitlements,I just cannot find NSCameraUsageDescription when I add row. What's the problem?Is this because I am not an official developer?
Posted Last updated
.
Post not yet marked as solved
0 Replies
12 Views
When you run the following SwiftUI code, images unrelated to animation will flicker. import SwiftUI struct TestAnimationView: View { @State private var effectFlg = false private let imageName = "image1" @State var rotationDegrees = 0.0 var body: some View { VStack() { Text("Rectangle") Rectangle() .foregroundColor(.blue) .frame(width: 100, height: 100) .padding(.bottom, 30) Text("PNG Image") if let _imageName = Bundle.main.path(forResource: imageName, ofType: "png") { Image(uiImage: UIImage(contentsOfFile: _imageName)!) .resizable() .frame(width: 100, height: 100) .padding(.bottom, 30) } Text("PNG Image") if let _imageName = Bundle.main.path(forResource: imageName, ofType: "png") { Image(uiImage: UIImage(contentsOfFile: _imageName)!) .resizable() .frame(width: 100, height: 100) // .scaleEffect(self.effectFlg ? 1 : 0.8) .rotationEffect(.degrees(self.rotationDegrees)) } Spacer() Button("Start Animation") { withAnimation(.default.repeatForever().speed(0.5)) { if self.effectFlg { rotationDegrees = 0.0 } else { rotationDegrees = 360.0 } self.effectFlg.toggle() } } } } }
Posted
by POCO2002.
Last updated
.
Post not yet marked as solved
2 Replies
529 Views
This is my test code. import SwiftUI extension View { @MainActor func render(scale: CGFloat) -> UIImage? { let renderer = ImageRenderer(content: self) renderer.scale = scale return renderer.uiImage } } struct ContentView: View { @Environment(\.colorScheme) private var colorScheme @State private var snapImg: UIImage = UIImage() var snap: some View { Text("I'm now is \(colorScheme == .dark ? "DARK" : "LIGHT") Mode!") .foregroundStyle(colorScheme == .dark ? .red : .green) } @ViewBuilder func snapEx() -> some View { VStack { Text("@ViewBuilder I'm now is \(colorScheme == .dark ? "DARK" : "LIGHT") Mode!") .foregroundStyle(colorScheme == .dark ? .red : .green) Text("@ViewBuilder I'm now is \(colorScheme == .dark ? "DARK" : "LIGHT") Mode!") .background(.pink) Text("@ViewBuilder I'm now is \(colorScheme == .dark ? "DARK" : "LIGHT") Mode!") .background(.purple) Text("@ViewBuilder I'm now is \(colorScheme == .dark ? "DARK" : "LIGHT") Mode!") .foregroundStyle(colorScheme == .dark ? .red : .green) Text("@ViewBuilder I'm now is \(colorScheme == .dark ? "DARK" : "LIGHT") Mode!") .foregroundStyle(colorScheme == .dark ? .red : .green) } } @ViewBuilder func snapView() -> some View { VStack { Text("Text") Text("Test2") .background(.green) snap snapEx() } } var body: some View { let snapView = snapView() VStack { snapView Image(uiImage: snapImg) Button("Snap") { snapImg = snapView.render(scale: UIScreen.main.scale) ?? UIImage() } } } } When using ImageRenderer, there are some problems with converting View to images. For example, Text cannot automatically modify the foreground color of Dark Mode. This is just a simple test code, not just Text. How should I solve it?
Posted
by jBanana.
Last updated
.
Post not yet marked as solved
0 Replies
50 Views
I've been trying to follow the "Supporting Continuity Camera in Your Mac App" article to implement the "Import from iPhone or iPad" menu for my MacOS app. I've been able to replicate most of the article in a test AppKit application but cannot do the same in my SwiftUI application. I'm not sure how to get the "NSMenuItemImportFromDeviceIdentifier" identifier into a SwiftUI Menu or create a NSMenu with a NSMenuItem for a SwiftUI app. I'm also not sure how to handle receiving the image in the SwiftUI environment. Any advice you might have is appreciated. Thanks!
Posted Last updated
.
Post not yet marked as solved
0 Replies
49 Views
I am trying to create a near real-time drawing of waveform data from within a SwiftUI app. The data is streaming in from the hardware and I've verified that the draw(in ctx: CGContext) override in my custom CALayer is getting called. I have added this custom CALayer class as a sublayer to a UIView instance that I am making available via the UIViewRepresentable protocol. The only time I see updated output from the CALayer is when I rotate the device and layout happens (I assume). How can I force SwiftUI to update every time I render new data in my CALayer? More Info: I'm porting an app from the Windows desktop. Previously, I tried to make this work by simply generating a new UIImage from a CGContext every time I wanted to update the display. I quickly exhausted memory with that technique because a new context is being created every time I call UIGraphicsImageRenderer(size:).image { context in }. What I really wanted was something equivalent to a GDI WritableBitmap. Apparently this animal allows a programmer to continuously update and re-use the contents. I could not figure out how to do this in Swift without dropping down to the old CGBitmapContext stuff written in C and even then I wasn't sure if that would give me a reusable context that I could output in SwiftUI each time I refreshed it. CALayer seemed like the answer. I welcome any feedback on a better way to do what I'm trying to accomplish.
Posted Last updated
.
Post not yet marked as solved
1 Replies
66 Views
I was coding a sidebar on macOS and folded it with my mouse, but every time I run the app, I can't see the sidebar, so I can't use the sidebar. If you add a new image once, you can't see the same, but the third window also shows the sidebar well. I don't know why It's similar when you run it on another computer at all. Current code import CoreData struct ContentView: View { @Environment(\.managedObjectContext) private var viewContext @State private var isSidebarVisible: Bool = true var body: some View { NavigationView { if isSidebarVisible { Sidebar() } MemoListView().environment(\.managedObjectContext, viewContext) } .frame(minWidth: 700, minHeight: 400) .toolbar { ToolbarItem(placement: .navigation) { Button(action: toggleSidebar) { Image(systemName: "sidebar.leading") } } } } private func toggleSidebar() { withAnimation { isSidebarVisible.toggle() } } struct Sidebar: View { @Environment(\.managedObjectContext) private var viewContext var body: some View { List { NavigationLink(destination: EasyWebListView().environment(\.managedObjectContext, viewContext)) { Label("Web Links", systemImage: "link") } NavigationLink(destination: MemoListView().environment(\.managedObjectContext, viewContext)) { Label("Memos", systemImage: "note.text") } NavigationLink(destination: ThemeListView().environment(\.managedObjectContext, viewContext)) { Label("Themes", systemImage: "photo.on.rectangle.angled") } NavigationLink(destination: AccessView().environment(\.managedObjectContext, viewContext)) { Label("Access Records", systemImage: "clock.fill") } } .navigationTitle("My App") } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) } } And the code used when there was a problem before. import CoreData struct ContentView: View { @Environment(\.managedObjectContext) private var viewContext @State private var isSidebarVisible: Bool = true var body: some View { NavigationView { Sidebar().environment(\.managedObjectContext, viewContext) MemoListView().environment(\.managedObjectContext, viewContext) } .frame(minWidth: 700, minHeight: 400) .toolbar { ToolbarItem(placement: .navigation) { Button(action: { withAnimation { isSidebarVisible.toggle() } }) { Image(systemName: "sidebar.leading") } } } } struct Sidebar: View { @Environment(\.managedObjectContext) private var viewContext var body: some View { List { NavigationLink(destination: EasyWebListView().environment(\.managedObjectContext, viewContext)) { Label("Web Links", systemImage: "link") } NavigationLink(destination: MemoListView().environment(\.managedObjectContext, viewContext)) { Label("Memos", systemImage: "note.text") } NavigationLink(destination: ThemeListView().environment(\.managedObjectContext, viewContext)) { Label("Themes", systemImage: "photo.on.rectangle.angled") } NavigationLink(destination: AccessView().environment(\.managedObjectContext, viewContext)) { Label("Access Records", systemImage: "clock.fill") } } .listStyle(SidebarListStyle()) .navigationTitle("My App") } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) } }
Posted Last updated
.
Post not yet marked as solved
2 Replies
66 Views
I'm developing an application using SwiftUI and SwiftData. The app includes a pricing section, and I'd like it to have an initial default value for pricing. Additionally, when updating the app on the App Store, I also want to update the prices. However, I'd like users to have the option to create their own prices if they don't want to use the ones I suggest. I want to save these prices obtained from the user because I'll be using these values for some operations later on. I'm wondering how to achieve this. Should I use SwiftData or UserDefaults for managing the data, or should I save the prices to a JSON file? If I opt for saving to a JSON file, would it be possible to update the JSON file when updating the app? Please feel free to ask any questions. Thank you in advance for your responses.
Posted Last updated
.
Post not yet marked as solved
1 Replies
56 Views
Hi all apple devs! I am a young developer who is completely new to everything programming. I am currently trying to develop an app where I want to use visionkit, but I can't for the life of me figure out how to implement its features. I've been stuck on this for several days, so I am now resorting to asking all of you experts for help! Your assistance would be immensely appreciated! I started to develop the app trying to exclusively use swiftUI to futureproof my app. Upon figuring out what visionkit is, to my understanding it is more compatible with UIkit? So I rewrote the part of my code that will use visionkit into a UIkit based view, to simplify the integration of visionkits features. It might just have overcomplicated my code? Can visionkit be easily implemented using only swiftUI? I noticed in the demo on the video tutorial the code is in a viewcontroller not a contentview, is this what makes my image unresponsive? My image is not interactable like her demo in the video, where in my code do I go wrong? Help a noob out! The desired user flow is like this: User selects an image through the "Open camera" or "Open Camera Roll" buttons. Upon selection the UIkit based view opens and the selected image is displayed on it. (This is where I want to implement visionkit features) User interacts with the image by touching on it, if touching on a subject, the subject should be lifted out of the rest of the image and be assigned to the editedImage, which in turn displays only the subject without the background on the contentview. (For now the image is assigned to editedimage by longpressing without any subjectlifting since I cant get visionkit to work as I want) Anyways, here's a code snippet of my peculiar effort to implement subject lifting and visionkit into my app:
Posted
by emol.
Last updated
.
Post not yet marked as solved
1 Replies
79 Views
So I have a simple view for my SwiftUI application below: import SwiftUI struct ContentView: View { var body: some View { List { ForEach(0..<4) { index in RowView(index: index) .accessibilityIdentifier("row") } } } } struct RowView: View { let index: Int var body: some View { HStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") Spacer() ButtonView(index: index) } .padding() } } struct ButtonView: View { let index: Int var body: some View { VStack { if index != 3 { Button(action: {}, label: { Text("Cancel") }) .accessibilityIdentifier("cancel_button") } Button(action: {}, label: { Text("Submit") }) .accessibilityIdentifier("submit_button") } } } My goal is to reference each cancel and submit button per row for a UI Test, which I have tried doing so here: let rowElements = app.tables.cells.matching(identifier: "row") for i in 0..<rowElements.count { let cancelButton = rowElements.element(boundBy: i).buttons["cancel_button"] let submitButton = rowElements.element(boundBy: i).buttons["submit_button"] XCTAssertTrue(cancelButton.exists, "Cancel button does not exist in row \(i)") XCTAssertTrue(submitButton.exists, "Submit button does not exist in row \(i)") } Even with the identifiers set like this my tests fail and say it cannot find the buttons labeled as they are with their specific identifiers or the rows. What is the correct way to reference elements if they are in a list or table for UI Testing? I'm specifically trying to use accessibility Identifiers to make my life easy.
Posted
by matson.
Last updated
.
Post not yet marked as solved
1 Replies
103 Views
SwiftUI in visionOS has a modifier called preferredSurroundingsEffect that takes a SurroundingsEffect. From what I can tell, there is only a single effect available: .systemDark. ImmersiveSpace(id: "MyView") { MyView() .preferredSurroundingsEffect(.systemDark) } I'd like to create another effect to tint the color of passthrough video if possible. Does anyone know how to create custom SurroundingsEffects?
Posted Last updated
.
Post not yet marked as solved
1 Replies
89 Views
Hi I reviewed this post: How to change navigation title color in swiftUI This seems to work fine if the intention is to apply the title color across an application. I would like to apply a different text title color selectively depending on the View being shown. And in some instances revert back to the color depending on the light and dark themes. Same result occurs using a viewmodifier or simply using onAppear and onDisappear with the title color is applied to all views. And if you do modify it in onDisappear, when you navigate back to another view which changes the color onAppear it has the same color as the previous view. The only way I've found this to work is using UIViewControllerRepresentable and handling the viewWillAppear and viewWillDisappear something like this: NavigationBarView( viewWillAppear: { nav in nav.navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.white] }, viewWillDisappear: { nav in nav.navigationBar.largeTitleTextAttributes = nil } ) Has anyone been successful in getting a different title text color to apply to different views using a modifier or onAppear and onDisappear? Appreciate any guidance.
Posted
by craigaps.
Last updated
.
Post not yet marked as solved
1 Replies
95 Views
I'm trying to figure out how to debug this issue. I have a fairly simple program that I built using the Hello World sample code as reference. Here is my code: import SwiftUI @main struct Core_USDZ_ViewerApp: App { var body: some Scene { // Main Menu scene // WindowGroup (id: "main-menu"){ CoreUsdzMenu() } // Scene that takes data as an input // for volumetric viewing // WindowGroup (for: URL.self) { $content in CoreUsdzVolume(url: content) } defaultValue: { URL(string: "https://developer.apple.com/augmented-reality/quick-look/models/pancakes/pancakes.usdz")! } .windowStyle(.volumetric) .defaultSize(width: 0.2, height: 0.3, depth: 0.3, in: .meters) // Full surround scene /* ImmersiveSpace { // put our immersive view here } */ } } In the simulator, this launches the main menu scene, but when installed on the Vision Pro using TestFlight it skips the main menu and goes straight to the second WindowGroup. Since the data isn't populated, it uses the defaultValue and just shows pancakes. I'm having trouble logging and debugging this issue, as I don't have access to the hardware myself. I have to push the code to TestFlight and wait for a coworker to test it. Does anyone have ideas of why this could be happening? Any help is appreciated. Logging and debugging tips especially. I'm used to just putting log messages in my code to debug, but maybe there are some breakpoint techniques I should be using here or something. Oh, also, here is my CoreUsdzMenu script: import SwiftUI import RealityKit import UniformTypeIdentifiers struct CoreUsdzMenu: View { @Environment(\.openWindow) private var openWindow @Environment(\.dismissWindow) private var dismissWindow @State var entity: Entity? = nil @State var showFilePicker: Bool = false init() { NSLog("In CoreUsdzMenu") } var body: some View { VStack{ Text("Core USDZ Viewer v1.1") .font(.title) .frame(width: 500.0, height: 100.0) /* usdz list HStack(spacing: 100.0) { Spacer() // Load the UsdzList view into the window! UsdzList() Spacer() }*/ /* button test for window Button { openWindow(value: usdzData[1].url) } label: { Text("open test window") }*/ // A view for displaying the loaded asset. /* RealityView( make: { content in // Add a placeholder entity to parent the entity to. // let placeholderEntity = Entity() placeholderEntity.name = "$__placeholder" if let loadedEntity = self.entity { placeholderEntity.addChild(loadedEntity) } content.add(placeholderEntity) }, update: { content in guard let placeholderEntity = content.entities.first(where: { $0.name == "$__placeholder" }) else { preconditionFailure("Unable to find placeholder entity") } // If there is a loaded entity, remove the old child, // and add the new one. // if let loadedEntity = self.entity { placeholderEntity.children.removeAll() placeholderEntity.addChild(loadedEntity) } } )*/ // A button that displays a file picker for loading a USDZ. // Button( action: { showFilePicker = true }, label: { Text("Load USDZ") } ) .padding() } // can import usdz and realityFile UTT types .fileImporter(isPresented: $showFilePicker, allowedContentTypes: [.usdz, .realityFile]) { result in // Get the URL of the USDZ picked by the user. // Guarded for errors. // guard let url = try? result.get() else { print("Unable to get URL") return } NSLog("In CoreUsdzMenu") // add new .usdz to our data list // for later!~ // use Observables n stuff //usdzData.addUsdz(url) // This task is just an asynchronous block of code. Not linked // to the RealityView explicitly; the update parameter of the // RealityView function responds when this task updates the entity. // Task { // As the app is sandboxed, permission needs to be // requested to access the file, as it's outside of // the sandbox. // if url.startAccessingSecurityScopedResource() { defer { url.stopAccessingSecurityScopedResource() } // Load the USDZ asynchronously. // On load, triggers RealityView's update. // //self.entity = try await Entity(contentsOf: url) // Try using the Volumetric Window to display the // content: // openWindow(value: url) } } } } } Thank you for reading!
Posted
by dganim8s.
Last updated
.
Post not yet marked as solved
0 Replies
82 Views
I know the short answer is, no, you cannot update an older version of your app… but it got me thinking…. could you make a new version of an app that supports older iOS versions and then quickly release another version of the app that supports iOS 16+ only? Wouldn‘t this effectively allow you to make a new version for for iOS 12 devices and still allow you to have iOS 16+ features that are needed for the current version? one of my apps needs features found in swiftUI (iOS 16+) but I’d like to update an old version that was not on swiftUI.
Posted
by Sinime.
Last updated
.
Post marked as solved
2 Replies
88 Views
I'm on my final steps 'polishing' my app before submitting to AppStore however there is something that bothers me. My Feedback section is somehow asking for the User's data in order to submit a Feedback. Do i need to include some sort of Privacy Policy for this? The app is working offline and is for educational purposes teaching users the basics of Swift in an interactive way. ... it doesn't require any sensitive information from the user apart from this form...Feedback is critical, any suggestion?
Posted
by OsmanM94.
Last updated
.
Post not yet marked as solved
3 Replies
2.1k Views
I have a SwiftUI menu Menu{ .... }, label : { Image(...).accessibility(identifier: "cardMenu") } I used to be able to bring up the menu (before upgrading to xcode 13 (ios15)) like this let app = XCUIApplication() app.launch() app.buttons["cardMenu"].tap() But now i am unable to see the identifier in app.buttons. Can't seem to find the identifier anymore. I've tried looking for the identifier in the other app fields and changing to use text instead of identifer. No luck. These tests used to work prior to the upgrade. Any help would be appreciated
Posted
by jsh22.
Last updated
.
Post not yet marked as solved
0 Replies
86 Views
I need to create a carousel component with the following requirements (sorted by relevance): Objectives Every image is 16:9 aspect ratio and resizes to fit the screen. Needs a zoom and pan functionality, possibly the same way as iOS Photos app. Needs to work both in landscape and portrait mode, with a smooth transition between orientations. When orientation changes, the image needs to be rotated to preserve the center of the image (like Photos app and hyperoslo/Lightbox) The component should only take the minimum necessary space. In most use cases, such component should have other subviews both above and below. Circularity. I would like the carousel to wrap around. What I tried: Using a TabView with .tabViewStyle(PageTabViewStyle()).indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .always)) modifiers. This didn't work: rotating the interface caused the view to get stuck between pages (it looks like it's a well known [bug]).(https://stackoverflow.com/questions/72435939/swiftui-tabview-is-not-working-properly-on-orientation-change). Implementing a single page (that is, an image view) using an UIScrollView and an UIViewRepresentable, then collecting them into an HStack. Unfortunately I need to use zoomScale and contentOffset properties of the UIScrollView outside of the UIViewRepresentable itself. The net result was that .init() was invoked for every image in the carousel at every rotation, causing severe stutters and an horrible rotation animation. Implementing the whole carousel using UIKit, and an UICollectionView, whose cells were an instance of UIScrollView. The problem is, the UIScrollView needs to recompute its constraints upon rotation but a cell is an instance of UIView, so it can't respond to rotations via viewWillTransition(to:CGSize, with: any UIViewControllerTransitionCoordinator). In the UICollectionView itself, you can only access the visible cells (one at a time is visible), and cells are cached, so even after rotating, some occasionally are presented on screen with the same appearance as before the rotation (some do, some don't, in the same UICollectionView). Also when rotating, it looks like the UIScrollView of the visible cell is being recreated, making it impossible to preserve the image center (I use this subclass of UIScrollView for this purpose). And the UICollectionView is taking the full window size, not just the bare minimum necessary space. Help: With all of this in mind, what options do I realistically have? If necessary I can raise the minimum iOS version to 16.0, even though I guess it doesn't make any significative difference since SwiftUI introduced MagnifyGesture only from iOS 17.0.
Posted Last updated
.
Post not yet marked as solved
1 Replies
124 Views
Hi Folks, I would like it so that when I press the button on the HomeScreen, the TabView hides and the toolbar item appears in its place. Currently, the toolbar item stacks on top of the TabView. However, when I try to hide the TabView, with an if condition for example, the screens turn black. I think it's because of the screen calls in the TabView. Is there an option to achieve what I want? I'm new to SwiftUI, so I'm very glad for any Solutions or advices. struct NavBar: View { var body: some View { TabView { HomeScreen() .tabItem { Label( "Home", systemImage: "house" ) } ... } } } struct HomeScreen: View { @State private var showDeleteButton = false var body: some View { Button("Show/Dissmiss Delete Button", action: { showDeleteButton.toggle() }).toolbar { if showDeleteButton { ToolbarItem(placement: .bottomBar) { Button("Delete", action: {}) } } } } }
Posted Last updated
.
Post not yet marked as solved
1 Replies
101 Views
I have a simple main app architecture: struct ContentView: View { @State private var isSignedIn = false @AppStorage("onboardingCompleted") var onboardingCompleted: Bool = false var body: some View { Group { if onboardingCompleted && isSignedIn { MainView() } else { OnboardingView() } } .onAppear() { signIn() } } OnboardingView is a NavigationView. MainView is a TabView. I switch between these when the user finishes onboarding. However, as the user taps on the finish button in the last onboarding step, this gets written to the console: Trying to pop to a missing destination - SwiftUI/NavigationBridge_PhoneTV.swift:213 - please file a bug report. In production, this causes a crash. I looked around and it seems it is an issue when you embed TabView inside NavigationView or vice versa? But here it's not the case, they are standalone and I switch between them. Any thoughts?
Posted Last updated
.