{"record":{"id":"4ac164d1ad186a51","repo":"dotnet/maui","slug":"removepage-is-not-supported-globally-on-ios-pleas","errorCode":null,"errorMessage":"RemovePage is not supported globally on iOS, please use a NavigationPage.","messagePattern":"RemovePage is not supported globally on iOS, please use a NavigationPage\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/iOS/Platform.cs","lineNumber":213,"sourceCode":"\t\t\t\tif (presentationStyle == UIKit.UIModalPresentationStyle.FullScreen)\n\t\t\t\t\tshouldFire = false; // This is mainly for backwards compatibility\n\t\t\t}\n\n\t\t\tif (_appeared && shouldFire)\n\t\t\t\tPage.GetCurrentPage()?.SendDisappearing();\n\n\t\t\t_modals.Add(modal);\n\n\t\t\tmodal.DescendantRemoved += HandleChildRemoved;\n\n\t\t\tif (_appeared)\n\t\t\t\treturn PresentModal(modal, _animateModals && animated);\n\t\t\treturn Task.FromResult<object>(null);\n\t\t}\n\n\t\tvoid INavigation.RemovePage(Page page)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"RemovePage is not supported globally on iOS, please use a NavigationPage.\");\n\t\t}\n\n\t\tpublic static SizeRequest GetNativeSize(VisualElement view, double widthConstraint, double heightConstraint)\n\t\t{\n\t\t\tPerformance.Start(out string reference);\n\n\t\t\tvar renderView = GetRenderer(view);\n\t\t\tif (renderView == null || renderView.NativeView == null)\n\t\t\t{\n\t\t\t\tif (view is IView iView)\n\t\t\t\t{\n\t\t\t\t\tApplication.Current?.FindMauiContext()?.CreateLogger<Platform>()?.LogWarning(\n\t\t\t\t\t\t\"Someone called Platform.GetNativeSize instead of going through the Handler.\");\n\n\t\t\t\t\treturn new SizeRequest(iView.Handler.GetDesiredSize(widthConstraint, heightConstraint));\n\t\t\t\t}\n\n\t\t\t\tPerformance.Stop(reference);","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/iOS/Platform.cs#L195-L231","documentation":"Platform.cs throws InvalidOperationException for INavigation.RemovePage. Removing a page from the global stack is not supported on iOS; only a NavigationPage-managed stack allows RemovePage operations.","triggerScenarios":"Calling MainPage.Navigation.RemovePage(page) when MainPage is not a NavigationPage.","commonSituations":"Shared code that manipulates the navigation stack from the global interface; switching the root away from NavigationPage while keeping RemovePage calls; cleaner-stack patterns after login flows without a NavigationPage.","solutions":["Use NavigationPage and call RemovePage on its Navigation property.","For login flows on iOS, rebuild the NavigationPage root rather than removing individual pages.","Refactor shared code to detect iOS and use NavigationPage semantics."],"exampleFix":"// before\nApplication.Current.MainPage.Navigation.RemovePage(loginPage);\n// after\n// MainPage is NavigationPage\nApplication.Current.MainPage.Navigation.RemovePage(loginPage);","handlingStrategy":"validation","validationCode":"if (!(Application.Current.MainPage is NavigationPage))\n    Application.Current.MainPage = new NavigationPage(Application.Current.MainPage);\nApplication.Current.MainPage.Navigation.RemovePage(page);","typeGuard":"static bool SupportsStackNavigation(Page p) => p is NavigationPage;","tryCatchPattern":null,"preventionTips":["Use NavigationPage for RemovePage on iOS.","Rebuild the NavigationPage root for login flows rather than removing pages.","Detect iOS in shared code to choose NavigationPage semantics."],"tags":["maui","xamarin-forms","ios","navigation","navigationpage","invalidoperation"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}