Hello! What UIKit API enables you to add a view below the navigation bar and extend the scroll edge effect below it in iOS 26? safeAreaBar is how you do it in SwiftUI but I need to achieve this design in my UIKit app (which has a collection view in a view controller in a navigation controller). struct ContentView: View { let segments = [First, Second, Third] @State private var selectedSegment = First var body: some View { NavigationStack { List(0..<50, id: .self) { i in Text(Row (i + 1)) } .safeAreaBar(edge: .top) { Picker(Segment, selection: $selectedSegment) { ForEach(segments, id: .self) { Text($0) } } .pickerStyle(.segmented) .padding(.horizontal) .padding(.bottom, 8) } .navigationTitle(Title) .navigationBarTitleDisplayMode(.inline) } } }
Search results for
swiftui
16,582 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
@Graphics and Games Engineer Thanks for the suggestion! I am trying to follow it and trying to compile shaders dynamically, so that I can use them as effects in SwiftUI, but it does not work. What I am doing is this (please don’t mind forced unwrapping): let shaderURL = Bundle.main.url(forResource: example-swiftui-shaders, withExtension: txt)! let source = try! String(contentsOf: shaderURL, encoding: .utf8) do { let device = MTLCreateSystemDefaultDevice()! let opt = MTLCompileOptions() opt.enableLogging = true let library = try device.makeLibrary( source: source, options: opt) print(ok, library) } catch { print(error, error) } I am getting a compilation error: Error Domain=MTLLibraryErrorDomain Code=3 program_source:10:10: fatal error: 'SwiftUI/SwiftUI_Metal.h' file not found #include ^~~~~~~~~~~~~~~~~~~~~~~~~ program_source:10:10: note: did not find header 'SwiftUI_Metal.h' in framework 'SwiftUI' (loaded from '/System/Library/Frameworks') UserInfo={NSLocalizedDescription
Topic:
Community
SubTopic:
Swift Student Challenge
Tags:
One screen in my app uses a navigation bar with some buttons added to the titleView and some buttons added as a customView of a single rightBarButtonItem. In iOS 26 (beta 9), if I switch to the home screen and back again, the titleView and rightBarButtonItem disappear and an overflow button (three dots) appears instead. Nothing happens when I click the overflow button. Here's a screen capture: https://youtu.be/tthRnMz98kA This also happens when I switch to another app, when I rotate the device or when I resize the app window. In all cases, there is enough room to show all the buttons, but they still disappear. I overrode the viewWillTransition function in my view controller and logged when that runs. I can see that if I switch to the home screen and back again before that runs (within one or two seconds), there's no problem. But once that runs, the navigation bar items disappear and the overflow button appears. I have not done anything to set up the overflow button and don't have any need to use it. The docum
Topic:
UI Frameworks
SubTopic:
UIKit
Problem Description: In a SwiftUI application, I've wrapped UIKit's UIPageViewController using UIViewControllerRepresentable, naming the wrapped class PagedInfiniteScrollView. This component causes navigation bar elements (title and buttons) to disappear. This issue only occurs in Low Power Mode on a physical device. Steps to Reproduce: Enable Low Power Mode on a physical device and open the app's home page. From the home page, open a detail sheet containing PagedInfiniteScrollView. This detail page include a navigation title and a toolbar button in the top-right corner. PagedInfiniteScrollView supports horizontal swiping to switch pages. Tap the toolbar button in the top-right corner of the detail page to open an edit sheet. Without making any changes, close the edit sheet and return to the detail page. On the detail page, swipe left and right on the PagedInfiniteScrollView. Expected Result: When swiping the PagedInfiniteScrollView, the navigation title and top-right toolbar button of the detail pag
Try this simple code: import SwiftUI import StoreKit struct ReviewView: View { @Environment(.requestReview) var requestReview var body: some View { Button(Leave a review) { requestReview() } } } When the Review Alert shows, the Not Now button is disabled for some reason!? It was always tappable in all iOS versions that I remember. And there is no way to opt out, unless the user taps on the stars first. Is it a bug or a feature? Thanks for looking into it!
Overview Tapping on ShareLink crashes the app when ShareLink is added in the toolbar with the placement of secondaryAction Feedback FB21337385 Note: Apple engineers please priorities this is a blocker and affects production apps and prevents us from going live. Environment Xcode: 26.2 (17C52) iOS: 26.2 iPadOS: 26.2 Reproduce Able to reproduce 100% both on Simulator and Device Isolation of the crash The crash happens only when the ShareLink is used with the placement .secondaryAction The crash doesn't 'happen when the ShareLink is used with the placement .primaryAction Code import SwiftUI struct ContentView: View { var body: some View { NavigationStack { Text(Hello, world!) .toolbar { ToolbarItem(placement: .primaryAction) { Button(Dummy) { print(dummy) } } // Tapping on share button will cause it to crash // Crash only happens when the ShareLink is used with placement .secondaryAction // It doesn't crash when placement is primaryAction ToolbarItem(placement: .secondaryAction) { ShareLink(item: Some s
I have installed the latest beta on my iPad , iPadOS 16.1 (20B5050f) On running in app in Playgrounds that has a TextField, external keyboard input do not seem to be working. Tapping on the Text field inserts the cursor but no text can be entered on my external keyboard. (TextEditor field also do not work) Tested with both a Smart Keyboard and a Magic Keyboard. The keyboard works to enter the code in playgrounds, so it is not a keyboard connection issue. Disconnecting the keyboard, the onscreen keyboard is displayed and works correctly. Is this a Playgrounds issue or an iPadOS 16.1 issue or a compatibility issue with Playgrounds & iPadOS 16.1 ? import SwiftUI struct ContentView: View { @State var field: String = Test input var body: some View { VStack { Image(systemName: globe) .imageScale(.large) .foregroundColor(.accentColor) Text(Hello, world!) TextField(, text: $field) .frame(height: 100) } } }
Thanks. Couldn't succeed after many tries of downloading and install (errors about permissions to read or execute...). I succeeded following the protocol described here: https://medium.com/@sergey-pekar/how-to-fix-annoying-xcode-26-not-building-swiftui-previews-error-cannot-execute-tool-metal-due-49564e20357c What I dont understand is that on my M1Max MBP, Metal was already OK without any setting, and I could compile my project once XCode 26 was downloaded and installed
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags:
With iOS 26.1 we started seeing a bug that only appears on iPhone Air. This bug is visible with simulators too. I have tried so many different ways to fix the issue, but Instruments Profiler is pointing at UIKitCore. We load a tab bar, when the user attempts to switch a tab, the app hangs and never recovers. It happens right as the animation of the Glass bubble is in progress. I have tried a UIKit Tab bar, a SwiftUI Tab bar. I tore out AppDelegate and did a direct @main SwiftUI entry for my application. This issue appears with every tab bar instance I try. I attempted to disable LiquidGlass by utilizing this flag UIDesignRequiresCompatibility in my plist, but the flag seems to be ignored by the system. I am not sure what else to try. I have a trace file if that is helpful. What else can I upload? Here is what the code looks like. struct ContentView: View { @State private var selectedTab = 2 var body: some View { TabView(selection: $selectedTab) { Text(Profile) .tabItem { Label(Me, systemImag
I'm trying to revamp the player into a floating style like Apple music. I use tabViewBottomAccessory with tabBarMinimizeBehavior. At the time, I noticed an issue that tabViewBottomAccessory would not automatically collapse when the scroll area was small (but still exceeded the screen height). tabViewBottomAccessory can only be automatically collapsed when the scroll area is large enough. Below is the simplest demo. I'm not sure if it's intentional or if it's a bug. Besides, I wonder if we can control it programmatically(expanded/inline)? struct ContentView: View { var body: some View { TabView { Tab(Numbers, systemImage: number.circle) { List { // 200 works well, but 20 not ForEach(0..<200) { index in Text((index)) } } } } .tabBarMinimizeBehavior(.onScrollDown) .tabViewBottomAccessory { HStack { Text(SwiftUI Demo App) } } } }
Like @vade above, trying to instrument a macOS app fails for me with the following unhelpful error message: Failed to start the recording: Failed starting ktrace session. Reading the comments above about iOS requiring iOS 26 to run the SwiftUI instrument, I’m now assuming that the same applies to macOS (I’m on 15.7.2). It would save everybody some confusion and time if it was made clear in Instruments that the SwiftUI instrument is not available for pre-26 targets. Ideally, disabling the SwiftUI instrument in the selection panel and having a help tip pop-up when hovering over it explaining that it requires 26 or later.
Topic:
Developer Tools & Services
SubTopic:
Instruments
Tags:
I am trying to perform swiftUI instrumentation on my ios app. whenever i hit the rocord button, the app launches on target device and closes with the error: Failed to start the recording: Failed starting ktrace session. How do i resolve this please?
We are facing a DNS resolution issue with a specific ISP, where our domain name does not resolve correctly using the system DNS. However, the same domain works as expected when a custom DNS resolver is used. On Android, this is straightforward to handle by configuring a custom DNS implementation using OkHttp / Retrofit. I am trying to implement a functionally equivalent solution in native iOS (Swift / SwiftUI). **Android Reference (Working Behavior) : ** val dns = DnsOverHttps.Builder() .client(OkHttpClient()) .url(https://cloudflare-dns.com/dns-query.toHttpUrl()) .bootstrapDnsHosts(InetAddress.getByName(1.1.1.1)).build() OkHttpClient.Builder().dns(dns).build() **Attempted iOS Approach ** I attempted the following approach : Resolve the domain to an IP address programmatically (using DNS over HTTPS) Connect directly to the resolved IP address Set the original domain in the Host HTTP header **DNS Resolution via DoH : ** func resolveDomain(domain: String) async throws -> String { guard let url = URL
Thanks for the post. Let's make sure there is no regression in the new version affecting state management in SwiftUI views. Only happens in iOS 26.1? What about 26.2? As a temporary workaround, you can try explicitly forcing a view update using the method on your view model or directly on the view if you're not using a view model. Do you have a focused sample project that shows the issue? Do you do something like this inside your view? @State private var counter = 0 var body: some View { VStack { Text(Counter: (counter)) .padding() Button(Increment) { counter += 1 (...) Please submit a focused sample for your specific case. It would help if you can provide a minimal reproducible example project demonstrating the issue. That'll help us better understand what's going on. If you're not familiar with preparing a test project, take a look at Creating a test project. Albert Pascual
Worldwide Developer Relations.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
As the title says, when I try to add a Toolbar with a Button to my NavigationSplitView I get a warning about satisfying constraints. Here is a minimal reproducible example: import SwiftUI @main struct ViewTestingApp: App { var body: some Scene { WindowGroup { NavigationSplitView { Text(Sidebar) .toolbar { ToolbarItem(placement: .topBarTrailing) { Button { debugPrint(Hello World!) } label: { Label(, systemImage: flame) } } } } content: { Text(Content) } detail: { Text(Detail) } } } } This is the specific warning I get: Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( , , , , ) W
Topic:
UI Frameworks
SubTopic:
SwiftUI