Search results for

“swiftui”

17,491 results found

Post

Replies

Boosts

Views

Activity

Restricting rotation
My iPhone App has requirement to be locked to portrait, except on certain screens like when showing a video player or other content. What is the best SwiftUI way to do this?
Topic: UI Frameworks SubTopic: SwiftUI
1
0
87
Jun ’26
Rich SwiftUI Rendering in the Siri Overlay
For intents that return complex markdown, code snippets, or structured layouts, what are the rendering capabilities and resource constraints of custom SwiftUI views returned via Snippet inside the Siri voice overlay? Are interactive controls (like buttons, copy-to-clipboard, or scroll views) supported inside the Siri-overlay SwiftUI container?
1
0
549
Jun ’26
Reply to microphone level monitoring
From a WidgetKit standpoint: There's no new capability for this, and it's not something widgets are designed to do. Widgets are intentionally timeline based to protect battery and system resources. The system decides when a widget is refreshed, and updates are mostly budgeted. However, on macOS the cadence is somewhat more relaxed than iOS, but even that depends on device conditions. In terms of how this can be achieved in general: The recommended approach is to write the meter value from the audio thread to a thread-safe primitive such as an atomic variable or lock-free ring buffer, then have the UI thread poll and redraw on a timer. For Cocoa/AppKit, CADisplayLink is the right tool for this. For SwiftUI, the idiomatic equivalent is TimelineView.
Topic: Audio SubTopic:
Audio Q&A
Jun ’26
Reply to Unexpected native popup during auth login/signout flow
Hi @harshit090891, You wrote: What triggers this popup during the authentication process? This is not the native authentication flow via the Authentication Services framework or the SignInWithAppleButton in SwiftUI. This alert is presented due to the web auth flow—using the Sign in with Apple REST API, instead of the native API flows mentioned above. If you follow the guidance in the sample code project below, the authentication flow will be presented without an explicit user confirmation to authenticate against the Services ID. This is because the native auth flow is already validated against the app's bundle ID (used as the Client ID). Cheers, Paris X Pinkney |  WWDR | DTS Engineer
Jun ’26
Reply to @State changes in Xcode 27 are causing variable definitions spanning multiple lines to produce unexpected compiler errors.
Thank you for filing this report. This looks to be brought with the changes of @State becoming a Swift macro rather than a property wrapper. I can see some activity in that feedback report you shared, I'll make sure it is seen by the relevant engineering team directly. Keep an eye on the report. There, updates will be provided to you - if they have questions or updates if your report has been resolved in any way. Please use the inline workaround you provided. I encourage you to test new versions as they are released and update us here and in the Feedback Report so the engineers have a good sense of timeline for this issue. For more information, see TN3211: Resolving SwiftUI source incompatibilities for State and ContentBuilder  Travis
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’26
@State changes in Xcode 27 are causing variable definitions spanning multiple lines to produce unexpected compiler errors.
On Xcode 27, the compiler incorrectly errors when a @State variable definition is placed on multiple lines. The code compiles without any issues on Xcode 26 and is valid Swift. The issue is fixed if the var definition is placed on a single line. The following code produces issues: @State internal var bodyText = Hi However, the code below works: @State internal var bodyText = Hi The issue is reproducible in any new project with a simple view: import SwiftUI import Playgrounds @main struct MyApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct ContentView: View { @State internal var bodyText = Hi var body: some View { Text(bodyText) .padding() } } #Preview { ContentView() } The expected behavior is for valid Swift code to not trigger compiler error. Filed FB23044343
1
0
428
Jun ’26
Reply to [iOS 27 Beta]: tabBarController(_:shouldSelect:) delegate method silently no longer called — breaking tab selection interception
That TabView uses UITabBarController under the hood is an internal implementation detail, and replacing its delegate or otherwise modifying the UITabBarController is not a supported path. If you need full control over a UITabBarController within a SwiftUI view hierarchy, you can use UIViewControllerRepresentable to wrap the tab bar controller.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jun ’26
Reply to Reorderable with Xcode previews
Hi, thanks for getting back Here is a code snippet where this issue will occur: import SwiftUI struct TestItem: Identifiable { let id = UUID() let color: Color } struct POSView: View { @State private var items = [ TestItem(color: .orange), TestItem(color: .purple), TestItem(color: .teal), TestItem(color: .blue), TestItem(color: .pink), TestItem(color: .green) ] let columns = [GridItem(.adaptive(minimum: 100))] var body: some View { ScrollView { LazyVGrid(columns: columns, spacing: 16) { ForEach(items) { item in RoundedRectangle(cornerRadius: 15) .fill(item.color.gradient) .frame(width: 100, height: 100) } .reorderable() } .reorderContainer(for: TestItem.self) { difference in items.apply(difference: difference) } .padding() } } } extension Array { mutating func apply( difference: ReorderDifference ) where Element: Identifiable, Element.ID: Sendable { guard let sourceIndex = firstIndex(where: { $0.id == difference.sources[0] }) else { return } let movedCard = remove(at: sourceIndex) var destination: In
Jun ’26
Reply to Is there a way to change the default scroll edge effect?
Is there a way to set the global default to soft for an app? We do not provide API for changing this app-wide, you'll need to use UIScrollEdgeEffect.style in UIKit or the scrollEdgeEffectstyle modifier in SwiftUI for each scroll view where this is relevant. especially since hard edge effects don't work with pinned views in LazyVStack We would be interested in looking into this more; if you could file a feedback or provide a example here, that would be greatly appreciated!
Topic: UI Frameworks SubTopic: General Tags:
Jun ’26
Reply to overriding default VoiceOver ordering
In general we recommend letting the system‘s default ordering persist here. VO users have an expectation when they open a new screen or app that their focus will be at the top, so they can navigate liberally through your content from start to finish. I would probably not recommend moving focus to the tab bar in your case for example. However, if you find cases where the default ordering is incorrect or confusing, you can use .accessibilitySortPriority() in SwiftUI to change the linear order. In UIKit, you can set the accessibilityElements property to a list of ordered accessibility elements to navigate through in the parent view to control the ordering.
Topic: General SubTopic:
Accessibility & Inclusion Q&A
Jun ’26
Reply to Displaying a processed image from AVCaptureVideoDataOutput in a swiftUI view?
To get the best performance, you want to render the CIImage using a SwiftUI view via Metal. There is a presentation from WWDC 22 that describes how to do this https://developer.apple.com/fr/videos/play/wwdc2022/10114/ There is also an associated sample code project: https://developer.apple.com/documentation/CoreImage/generating-an-animation-with-a-core-image-render-destination
Topic: Video SubTopic:
Video Q&A
Jun ’26
Code sharing between targets and what’s the best structure for doing so
I guess this is in parts a multiplatform / SwiftData / WidgetKit and SwiftUI question. my usual problem is I start an app and then quickly find myself wanting to add widgets / controls / AppIntents and expand across multiple targets. for example I start with an iOS only target and expand to watchOS, iPadOS and visionOS. But since this targets and the apps I want to build are very distinct, I don’t find myself using the multiplatform target but instead a target per platform. This (at least from my understanding) then also comes with the benefit that I can add a WidgetKit extension and all targets use it. now this is the base idea, but here come the many questions I have had issues finding a clear answer and guidance on over the last years. When sharing SwiftUI views and business logic for DRY, whats the actual best way to do that? A „core“ swift package, or a library? what are the implications of choosing one over the other? I understand that widgets are separately scoped and sandboxed from m
1
0
148
Jun ’26
Reply to Recommended practice for VoiceOver accessibility label aggregation in UIKit (SwiftUI .combine equivalent)
We don't have any APIs to automatically combine elements in UIKit like we do in SwiftUI, but manually appending labels of UI elements together is the right approach. Comma separating the labels is typically the right approach, and this is actually what SwiftUI's combine does under the hood. Even for non-latin scripts, the built in synthesizers should apply a pause when encountering a comma. If you are not seeing a pause added when using a comma in a specific language, please file a feedback report so that we can take a look (especially if you are seeing combine in SwiftUI adding a pause for the same language)!
Topic: General SubTopic:
Accessibility & Inclusion Q&A
Jun ’26
Restricting rotation
My iPhone App has requirement to be locked to portrait, except on certain screens like when showing a video player or other content. What is the best SwiftUI way to do this?
Topic: UI Frameworks SubTopic: SwiftUI
Replies
1
Boosts
0
Views
87
Activity
Jun ’26
Reply to Clustering on MapKit for SwiftUI iOS17+
@Frameworks Engineer iOS27 launched in beta a few days ago - Are there any news about this clustering feature - or any other Map additions in SwiftUI? Currently in our team we're stuck with UIKit for the map.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’26
Rich SwiftUI Rendering in the Siri Overlay
For intents that return complex markdown, code snippets, or structured layouts, what are the rendering capabilities and resource constraints of custom SwiftUI views returned via Snippet inside the Siri voice overlay? Are interactive controls (like buttons, copy-to-clipboard, or scroll views) supported inside the Siri-overlay SwiftUI container?
Replies
1
Boosts
0
Views
549
Activity
Jun ’26
Reply to microphone level monitoring
From a WidgetKit standpoint: There's no new capability for this, and it's not something widgets are designed to do. Widgets are intentionally timeline based to protect battery and system resources. The system decides when a widget is refreshed, and updates are mostly budgeted. However, on macOS the cadence is somewhat more relaxed than iOS, but even that depends on device conditions. In terms of how this can be achieved in general: The recommended approach is to write the meter value from the audio thread to a thread-safe primitive such as an atomic variable or lock-free ring buffer, then have the UI thread poll and redraw on a timer. For Cocoa/AppKit, CADisplayLink is the right tool for this. For SwiftUI, the idiomatic equivalent is TimelineView.
Topic: Audio SubTopic:
Audio Q&A
Replies
Boosts
Views
Activity
Jun ’26
Reply to Unexpected native popup during auth login/signout flow
Hi @harshit090891, You wrote: What triggers this popup during the authentication process? This is not the native authentication flow via the Authentication Services framework or the SignInWithAppleButton in SwiftUI. This alert is presented due to the web auth flow—using the Sign in with Apple REST API, instead of the native API flows mentioned above. If you follow the guidance in the sample code project below, the authentication flow will be presented without an explicit user confirmation to authenticate against the Services ID. This is because the native auth flow is already validated against the app's bundle ID (used as the Client ID). Cheers, Paris X Pinkney |  WWDR | DTS Engineer
Replies
Boosts
Views
Activity
Jun ’26
Reply to @State changes in Xcode 27 are causing variable definitions spanning multiple lines to produce unexpected compiler errors.
Thank you for filing this report. This looks to be brought with the changes of @State becoming a Swift macro rather than a property wrapper. I can see some activity in that feedback report you shared, I'll make sure it is seen by the relevant engineering team directly. Keep an eye on the report. There, updates will be provided to you - if they have questions or updates if your report has been resolved in any way. Please use the inline workaround you provided. I encourage you to test new versions as they are released and update us here and in the Feedback Report so the engineers have a good sense of timeline for this issue. For more information, see TN3211: Resolving SwiftUI source incompatibilities for State and ContentBuilder  Travis
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’26
@State changes in Xcode 27 are causing variable definitions spanning multiple lines to produce unexpected compiler errors.
On Xcode 27, the compiler incorrectly errors when a @State variable definition is placed on multiple lines. The code compiles without any issues on Xcode 26 and is valid Swift. The issue is fixed if the var definition is placed on a single line. The following code produces issues: @State internal var bodyText = Hi However, the code below works: @State internal var bodyText = Hi The issue is reproducible in any new project with a simple view: import SwiftUI import Playgrounds @main struct MyApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct ContentView: View { @State internal var bodyText = Hi var body: some View { Text(bodyText) .padding() } } #Preview { ContentView() } The expected behavior is for valid Swift code to not trigger compiler error. Filed FB23044343
Replies
1
Boosts
0
Views
428
Activity
Jun ’26
Reply to [iOS 27 Beta]: tabBarController(_:shouldSelect:) delegate method silently no longer called — breaking tab selection interception
That TabView uses UITabBarController under the hood is an internal implementation detail, and replacing its delegate or otherwise modifying the UITabBarController is not a supported path. If you need full control over a UITabBarController within a SwiftUI view hierarchy, you can use UIViewControllerRepresentable to wrap the tab bar controller.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jun ’26
Reply to Reorderable with Xcode previews
Hi, thanks for getting back Here is a code snippet where this issue will occur: import SwiftUI struct TestItem: Identifiable { let id = UUID() let color: Color } struct POSView: View { @State private var items = [ TestItem(color: .orange), TestItem(color: .purple), TestItem(color: .teal), TestItem(color: .blue), TestItem(color: .pink), TestItem(color: .green) ] let columns = [GridItem(.adaptive(minimum: 100))] var body: some View { ScrollView { LazyVGrid(columns: columns, spacing: 16) { ForEach(items) { item in RoundedRectangle(cornerRadius: 15) .fill(item.color.gradient) .frame(width: 100, height: 100) } .reorderable() } .reorderContainer(for: TestItem.self) { difference in items.apply(difference: difference) } .padding() } } } extension Array { mutating func apply( difference: ReorderDifference ) where Element: Identifiable, Element.ID: Sendable { guard let sourceIndex = firstIndex(where: { $0.id == difference.sources[0] }) else { return } let movedCard = remove(at: sourceIndex) var destination: In
Replies
Boosts
Views
Activity
Jun ’26
Reply to Is there a way to change the default scroll edge effect?
Is there a way to set the global default to soft for an app? We do not provide API for changing this app-wide, you'll need to use UIScrollEdgeEffect.style in UIKit or the scrollEdgeEffectstyle modifier in SwiftUI for each scroll view where this is relevant. especially since hard edge effects don't work with pinned views in LazyVStack We would be interested in looking into this more; if you could file a feedback or provide a example here, that would be greatly appreciated!
Topic: UI Frameworks SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jun ’26
Xcode 27: SwiftUI Preview with SwiftData doesn't work
Overview When a project contains SwiftData and the Preview uses a in memory database, SwiftUI preview doesn't show the data Have a look at the ContentView preview Environment Xcode 27.0 beta (27A5194q) 26.5.1 (25F80) Feedback FB23041713 Please can you have a look at the feedback, it also has a sample project and screenshot
Replies
1
Boosts
0
Views
484
Activity
Jun ’26
Reply to overriding default VoiceOver ordering
In general we recommend letting the system‘s default ordering persist here. VO users have an expectation when they open a new screen or app that their focus will be at the top, so they can navigate liberally through your content from start to finish. I would probably not recommend moving focus to the tab bar in your case for example. However, if you find cases where the default ordering is incorrect or confusing, you can use .accessibilitySortPriority() in SwiftUI to change the linear order. In UIKit, you can set the accessibilityElements property to a list of ordered accessibility elements to navigate through in the parent view to control the ordering.
Topic: General SubTopic:
Accessibility & Inclusion Q&A
Replies
Boosts
Views
Activity
Jun ’26
Reply to Displaying a processed image from AVCaptureVideoDataOutput in a swiftUI view?
To get the best performance, you want to render the CIImage using a SwiftUI view via Metal. There is a presentation from WWDC 22 that describes how to do this https://developer.apple.com/fr/videos/play/wwdc2022/10114/ There is also an associated sample code project: https://developer.apple.com/documentation/CoreImage/generating-an-animation-with-a-core-image-render-destination
Topic: Video SubTopic:
Video Q&A
Replies
Boosts
Views
Activity
Jun ’26
Code sharing between targets and what’s the best structure for doing so
I guess this is in parts a multiplatform / SwiftData / WidgetKit and SwiftUI question. my usual problem is I start an app and then quickly find myself wanting to add widgets / controls / AppIntents and expand across multiple targets. for example I start with an iOS only target and expand to watchOS, iPadOS and visionOS. But since this targets and the apps I want to build are very distinct, I don’t find myself using the multiplatform target but instead a target per platform. This (at least from my understanding) then also comes with the benefit that I can add a WidgetKit extension and all targets use it. now this is the base idea, but here come the many questions I have had issues finding a clear answer and guidance on over the last years. When sharing SwiftUI views and business logic for DRY, whats the actual best way to do that? A „core“ swift package, or a library? what are the implications of choosing one over the other? I understand that widgets are separately scoped and sandboxed from m
Replies
1
Boosts
0
Views
148
Activity
Jun ’26
Reply to Recommended practice for VoiceOver accessibility label aggregation in UIKit (SwiftUI .combine equivalent)
We don't have any APIs to automatically combine elements in UIKit like we do in SwiftUI, but manually appending labels of UI elements together is the right approach. Comma separating the labels is typically the right approach, and this is actually what SwiftUI's combine does under the hood. Even for non-latin scripts, the built in synthesizers should apply a pause when encountering a comma. If you are not seeing a pause added when using a comma in a specific language, please file a feedback report so that we can take a look (especially if you are seeing combine in SwiftUI adding a pause for the same language)!
Topic: General SubTopic:
Accessibility & Inclusion Q&A
Replies
Boosts
Views
Activity
Jun ’26