Search results for

“swiftui”

17,110 results found

Post

Replies

Boosts

Views

Activity

Now Available: Wishlist Sample Code for SwiftUI
We’ve just added a new sample code project to the SwiftUI Essentials documentation! If you attended the recent SwiftUI foundations: Build great apps with SwiftUI activity, you might recognize Wishlist, our travel-planning sample app. You can now explore and download the complete project here
0
0
75
Mar ’26
Glass Effect Label Shadow Clipping During Morph Animation
Hi all, I’m experiencing a visual bug when applying the glass effect to a Label in Liquid Glass (current version 26.2 on simulator; also reproducible in 26.3.1 on device). Issue: On a label with .glassEffect(.regular), when collapsing via morph animation, the shadow is clipped during the animation, and then suddenly pops back to its un-clipped state, resulting in a jarring visual effect. Minimal Example: import SwiftUI struct ContentView: View { var body: some View { Menu { Button(Duplicate, action: {}) Button(Rename, action: {}) Button(Delete…, action: {}) } label: { Label(PDF, systemImage: doc.fill) .padding() .glassEffect(.regular) } } } #Preview { ContentView() } I am not sure if I am misusing the .glassEffect() on the label and maybe there is another more native way of achieving this look? Any advice or workaround suggestions would be greatly appreciated!
2
0
208
Mar ’26
Simulator was shutdown during an update
I am trying to preview my SwiftUI views but Xcode Preview Canvas failing. I tried everything that I found at internet but nothing works. Finally I created a new iOS project that contains only a view import SwiftUI struct ContentView: View { var body: some View { VStack { Image(systemName: globe) .imageScale(.large) .foregroundStyle(.tint) Text(Hello, world!) } .padding() } } #Preview { ContentView() } Even this view cannot be previewed The error is Simulator was shutdown during an update Simulator [3E0DB935-C4C2-4566-BA48-8E21564C207C] failed to boot and may have crashed. I tried to restart xCode, restart Mac, download ios 26.0 sdk and created a simulator with that sdk but nothing helped. Do you have an idea?
1
0
119
Mar ’26
Reply to Xcode 26.3 not rendering Unicode/Emoji in Simulator or Canvas
Thanks so much for this post and thanks for your patience on my replay. When Unicode characters and emojis render perfectly on a physical device but appear as blank spaces or empty boxes in the Simulator and SwiftUI Canvas, in my opinion it means the Color Emoji font is missing and this is corrupted, or failing to load inside the Simulator Runtime. Because the SwiftUI Canvas uses the exact same underlying simulator infrastructure as the standalone Simulator app, both break at the same time. We identified this a bug and I would encourage you to use the physical device or to download the latest beta simulators iOS 24.4 RC https://developer.apple.com/download/os/ and let me know it the issue has been fixed. Here are the most effective ways to resolve this issue: Open Xcode and go to Xcode > Settings (or Preferences) > Platforms. Find the iOS Simulator runtime you are currently using (e.g., iOS 26.3). Right-click (or Control-click) it and select Delete. Once deleted, click the + button at
Mar ’26
PhaseAnimator doesn't reflect @Observable state changes after animation settles
I ran into a behavior with PhaseAnimator that I'm not sure is a bug or by design. I'd appreciate any insight. The Problem When an @Observable property is read only inside a PhaseAnimator content closure, changes to that property are ignored after the animation cycle completes and reaches its resting state. The UI gets stuck showing stale data. Minimal Reproduction I've put together a simple demo with two views side by side, both driven by the same ViewModel and toggled by the same button: BrokenView — receives an @Observable object and reads its property inside PhaseAnimator. After the animation completes, toggling the property has no visible effect. FixedView — receives the same value as a Bool parameter. Updates correctly every time because view's parameter has changed. import SwiftUI @Observable class ViewModel { var isError = false } struct BrokenView: View { let viewModel: ViewModel @State private var trigger = false var body: some View { VStack(spacing: 20) { Text(Broken (@Observable)).font(.he
0
0
117
Mar ’26
Reply to Xcode 16 warning about missing symbols of static framework
I am seeing a similar issue, but only for my Mac Catalyst archive on XCode 26. My app is a SwiftUI application that embeds an Objective-C framework built from a separate Xcode project. The framework binary itself does have UUIDs, but when I inspect the .xcarchive, the corresponding framework dSYM is missing from the archive’s dSYMs folder. What is confusing is that this does not happen for the iOS build. I use the same framework target, and when I archive the iOS app and upload to TestFlight, I do not get the warning. The problem only appears when I archive the Mac Catalyst version. So in summary: • The embedded framework binary is present in the archive • The framework executable has valid UUIDs • The app archive’s dSYMs folder does not contain the matching dSYM for that embedded framework • This only happens for Mac Catalyst • The same setup works correctly for iOS Has anyone seen Catalyst archives skip generating or packaging dSYMs for embedded frameworks, even though the binary itself contains de
Mar ’26
Reply to EASession(accessory:forProtocol:) always returns nil — MFI accessory iAP2
We have a custom MFI-certified accessory communicating over USB-C using ExternalAccessory. The app calls EASession(accessory:forProtocol:) after receiving EAAccessoryDidConnect, but it always returns nil. We never get past session creation. A few questions: Ruling out an obvious issue, you're testing on a real iOS device, not the simulator, correct? Is this a SwiftUI or UIKit app? If this is a SwiftUI app, try integrating ExternalAccessory support into a basic UIKit project and then retest. I'm not sure what the current situation is, but there are longstanding issues with the ExternalAccessory framework and SwiftUI, and #3 is the easiest way to rule out any other issues. __ Kevin Elliott DTS Engineer, CoreOS/Hardware
Topic: App & System Services SubTopic: Hardware Tags:
Mar ’26
Reply to File Export from iOS - eventually import too
Your code that wraps UIActivityViewController with UIViewControllerRepresentable and presents it in SwiftUI looks good to me. I've tried running the code on my iOS simulator (iOS 26.2 23C54) and here is the behavior I see: When sharing one single item, the code demonstrates the behavior as I described. When sharing two items (by using var shareItems: [Any] { [textItem1, textItem1] }), the Save as field isn't editable, and so there is indeed no way to specify the file names. Also, two files are generated, one for each item. So it's not that the way you present UIActivityViewController has anything wrong; it's that UIActivityViewController doesn't allow you to specify the file names when sharing multiple items. I don't see any way that can change the behavior because the UI of UIActivityViewController is system-provided. Please feel free to file a feedback report to request the feature you would like to have. For now, you might consider sharing one single item, if that is appropriate to your use case.
Topic: UI Frameworks SubTopic: SwiftUI
Mar ’26
CloudKit: Efficient way to get user's rank in leaderboard without fetching all records?
CloudKit: Efficient way to get user's rank in leaderboard without fetching all records? I'm building a leaderboard feature using CloudKit's public database and need advice on the best approach to calculate a user's rank efficiently. Current Setup Record Structure: Record Type: LeaderboardScore Fields: period (String): daily, weekly, monthly, allTime score (Int): User's score profile (Reference): Link to user's profile achievedAt (Date): Timestamp Leaderboard Display: Initially fetch first 15 users (sorted by score descending) Paginate to load more as user scrolls Show total player count Show current user's rank (even if not in top 15) The Challenge I can fetch the first 15 users easily with a sorted query, but I need to display the current user's rank regardless of their position. For example: User could be ranked #1 (in top 15) ✅ Easy User could be ranked #247 (not in top 15) ❌ How to get this efficiently? My Current Approach Query records with scores higher than the user's score and count them: // Count how
3
0
249
Mar ’26
Reply to File Export from iOS - eventually import too
Thanks for these answers, but I'm afraid I need a bit more help. How do you go about presenting the activityViewController? Could you show this in a small example app? I had previously written this and it does share but it creates 2 files, and doesn't present any way to rename the file. import SwiftUI import UIKit struct ContentView: View { @State private var showShareSheet = false @State private var textItem1 = @State private var textItem2 = // @State private var shareItems: [Any] = [ // Check out this file!, // URL(fileURLWithPath: FileManager.documentsDirectory.path()) // Replace with a real file URL // ] var shareItems: [Any] { [ textItem1, textItem2 // URL(fileURLWithPath: TinySavedItems) ] } var body: some View { VStack { TextField(enter text, text: $textItem1) .padding() TextField(enter text, text: $textItem2) .padding() Button(Share, systemImage: square.and.arrow.up) { showShareSheet = true } .sheet(isPresented: $showShareSheet) { ActivityViewController(activityItems: shareItems) } } } stru
Topic: UI Frameworks SubTopic: SwiftUI
Mar ’26
Reply to AVAudioSession.outputVolume does not reflect system volume changes made while app is in background
I had the same problem even with Audio, AirPlay and Picture in Picture background mode enabled and with all the AVAudioSession.setActive(true) and AVAudioSession.setCategory(...) calls. We run some tests and it seems Apple made things more restrictive since iOS 18 (it was working on iOS 17.6). The only fix I found is to use the good old MPVolumeView as a substitute, but there's a catch - it's mandatory to add it to UI otherwise it will always return volume of 0. In SwiftUI it was as simple as creating a UI component: import MediaPlayer import SwiftUI struct VolumeSlider: UIViewRepresentable { private let volumeView: MPVolumeView = MPVolumeView() func makeUIView(context: Context) -> MPVolumeView { return volumeView } func updateUIView(_ view: MPVolumeView, context: Context) {} func getVolume() -> Float { if let slider = volumeView.subviews.first(where: { $0 is UISlider }) as? UISlider { return slider.value } return AVAudioSession.sharedInstance().outputVolume } } And then in your SwiftUI
Topic: Media Technologies SubTopic: Audio Tags:
Mar ’26
What steps should I follow to get started with iOS development?
Hey everyone 👋 I’m starting my journey in iOS app development coming from a Java background and I already have an app idea but want to approach things the right way so I’d love your guidance What AI tools do you recommend for coding debugging and learning Swift or SwiftUI 🤖 how do you approach app design 🎨 and where do you find UI inspiration graphics or useful resources for building apps 🚀 any tips or lessons learned would really help 🙏
1
0
76
Mar ’26
Reply to File Export from iOS - eventually import too
No, you don't need to write the data as a file to your the app’s document directory. With UIActivityViewController, you can share a piece of text, as shown in the following code example let text = This is a piece of text. let activityViewController = UIActivityViewController(activityItems: [text], applicationActivities: nil) With that, when activityViewController is presented, it shows the system-provided share UI that contains a Save to Files button, which allows you to save the text as a file to iCloud Drive. Tapping the button shows a UI that has a Save as field for you to input the file name for the taget file. To import a file, consider using SwiftUI fileImporter. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI
Mar ’26
Now Available: Wishlist Sample Code for SwiftUI
We’ve just added a new sample code project to the SwiftUI Essentials documentation! If you attended the recent SwiftUI foundations: Build great apps with SwiftUI activity, you might recognize Wishlist, our travel-planning sample app. You can now explore and download the complete project here
Replies
0
Boosts
0
Views
75
Activity
Mar ’26
Glass Effect Label Shadow Clipping During Morph Animation
Hi all, I’m experiencing a visual bug when applying the glass effect to a Label in Liquid Glass (current version 26.2 on simulator; also reproducible in 26.3.1 on device). Issue: On a label with .glassEffect(.regular), when collapsing via morph animation, the shadow is clipped during the animation, and then suddenly pops back to its un-clipped state, resulting in a jarring visual effect. Minimal Example: import SwiftUI struct ContentView: View { var body: some View { Menu { Button(Duplicate, action: {}) Button(Rename, action: {}) Button(Delete…, action: {}) } label: { Label(PDF, systemImage: doc.fill) .padding() .glassEffect(.regular) } } } #Preview { ContentView() } I am not sure if I am misusing the .glassEffect() on the label and maybe there is another more native way of achieving this look? Any advice or workaround suggestions would be greatly appreciated!
Replies
2
Boosts
0
Views
208
Activity
Mar ’26
Simulator was shutdown during an update
I am trying to preview my SwiftUI views but Xcode Preview Canvas failing. I tried everything that I found at internet but nothing works. Finally I created a new iOS project that contains only a view import SwiftUI struct ContentView: View { var body: some View { VStack { Image(systemName: globe) .imageScale(.large) .foregroundStyle(.tint) Text(Hello, world!) } .padding() } } #Preview { ContentView() } Even this view cannot be previewed The error is Simulator was shutdown during an update Simulator [3E0DB935-C4C2-4566-BA48-8E21564C207C] failed to boot and may have crashed. I tried to restart xCode, restart Mac, download ios 26.0 sdk and created a simulator with that sdk but nothing helped. Do you have an idea?
Replies
1
Boosts
0
Views
119
Activity
Mar ’26
Reply to Xcode 26.3 not rendering Unicode/Emoji in Simulator or Canvas
Thanks so much for this post and thanks for your patience on my replay. When Unicode characters and emojis render perfectly on a physical device but appear as blank spaces or empty boxes in the Simulator and SwiftUI Canvas, in my opinion it means the Color Emoji font is missing and this is corrupted, or failing to load inside the Simulator Runtime. Because the SwiftUI Canvas uses the exact same underlying simulator infrastructure as the standalone Simulator app, both break at the same time. We identified this a bug and I would encourage you to use the physical device or to download the latest beta simulators iOS 24.4 RC https://developer.apple.com/download/os/ and let me know it the issue has been fixed. Here are the most effective ways to resolve this issue: Open Xcode and go to Xcode > Settings (or Preferences) > Platforms. Find the iOS Simulator runtime you are currently using (e.g., iOS 26.3). Right-click (or Control-click) it and select Delete. Once deleted, click the + button at
Replies
Boosts
Views
Activity
Mar ’26
PhaseAnimator doesn't reflect @Observable state changes after animation settles
I ran into a behavior with PhaseAnimator that I'm not sure is a bug or by design. I'd appreciate any insight. The Problem When an @Observable property is read only inside a PhaseAnimator content closure, changes to that property are ignored after the animation cycle completes and reaches its resting state. The UI gets stuck showing stale data. Minimal Reproduction I've put together a simple demo with two views side by side, both driven by the same ViewModel and toggled by the same button: BrokenView — receives an @Observable object and reads its property inside PhaseAnimator. After the animation completes, toggling the property has no visible effect. FixedView — receives the same value as a Bool parameter. Updates correctly every time because view's parameter has changed. import SwiftUI @Observable class ViewModel { var isError = false } struct BrokenView: View { let viewModel: ViewModel @State private var trigger = false var body: some View { VStack(spacing: 20) { Text(Broken (@Observable)).font(.he
Replies
0
Boosts
0
Views
117
Activity
Mar ’26
Reply to Xcode 16 warning about missing symbols of static framework
I am seeing a similar issue, but only for my Mac Catalyst archive on XCode 26. My app is a SwiftUI application that embeds an Objective-C framework built from a separate Xcode project. The framework binary itself does have UUIDs, but when I inspect the .xcarchive, the corresponding framework dSYM is missing from the archive’s dSYMs folder. What is confusing is that this does not happen for the iOS build. I use the same framework target, and when I archive the iOS app and upload to TestFlight, I do not get the warning. The problem only appears when I archive the Mac Catalyst version. So in summary: • The embedded framework binary is present in the archive • The framework executable has valid UUIDs • The app archive’s dSYMs folder does not contain the matching dSYM for that embedded framework • This only happens for Mac Catalyst • The same setup works correctly for iOS Has anyone seen Catalyst archives skip generating or packaging dSYMs for embedded frameworks, even though the binary itself contains de
Replies
Boosts
Views
Activity
Mar ’26
Reply to EASession(accessory:forProtocol:) always returns nil — MFI accessory iAP2
We have a custom MFI-certified accessory communicating over USB-C using ExternalAccessory. The app calls EASession(accessory:forProtocol:) after receiving EAAccessoryDidConnect, but it always returns nil. We never get past session creation. A few questions: Ruling out an obvious issue, you're testing on a real iOS device, not the simulator, correct? Is this a SwiftUI or UIKit app? If this is a SwiftUI app, try integrating ExternalAccessory support into a basic UIKit project and then retest. I'm not sure what the current situation is, but there are longstanding issues with the ExternalAccessory framework and SwiftUI, and #3 is the easiest way to rule out any other issues. __ Kevin Elliott DTS Engineer, CoreOS/Hardware
Topic: App & System Services SubTopic: Hardware Tags:
Replies
Boosts
Views
Activity
Mar ’26
Reply to File Export from iOS - eventually import too
Your code that wraps UIActivityViewController with UIViewControllerRepresentable and presents it in SwiftUI looks good to me. I've tried running the code on my iOS simulator (iOS 26.2 23C54) and here is the behavior I see: When sharing one single item, the code demonstrates the behavior as I described. When sharing two items (by using var shareItems: [Any] { [textItem1, textItem1] }), the Save as field isn't editable, and so there is indeed no way to specify the file names. Also, two files are generated, one for each item. So it's not that the way you present UIActivityViewController has anything wrong; it's that UIActivityViewController doesn't allow you to specify the file names when sharing multiple items. I don't see any way that can change the behavior because the UI of UIActivityViewController is system-provided. Please feel free to file a feedback report to request the feature you would like to have. For now, you might consider sharing one single item, if that is appropriate to your use case.
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Mar ’26
CloudKit: Efficient way to get user's rank in leaderboard without fetching all records?
CloudKit: Efficient way to get user's rank in leaderboard without fetching all records? I'm building a leaderboard feature using CloudKit's public database and need advice on the best approach to calculate a user's rank efficiently. Current Setup Record Structure: Record Type: LeaderboardScore Fields: period (String): daily, weekly, monthly, allTime score (Int): User's score profile (Reference): Link to user's profile achievedAt (Date): Timestamp Leaderboard Display: Initially fetch first 15 users (sorted by score descending) Paginate to load more as user scrolls Show total player count Show current user's rank (even if not in top 15) The Challenge I can fetch the first 15 users easily with a sorted query, but I need to display the current user's rank regardless of their position. For example: User could be ranked #1 (in top 15) ✅ Easy User could be ranked #247 (not in top 15) ❌ How to get this efficiently? My Current Approach Query records with scores higher than the user's score and count them: // Count how
Replies
3
Boosts
0
Views
249
Activity
Mar ’26
Reply to File Export from iOS - eventually import too
Thanks for these answers, but I'm afraid I need a bit more help. How do you go about presenting the activityViewController? Could you show this in a small example app? I had previously written this and it does share but it creates 2 files, and doesn't present any way to rename the file. import SwiftUI import UIKit struct ContentView: View { @State private var showShareSheet = false @State private var textItem1 = @State private var textItem2 = // @State private var shareItems: [Any] = [ // Check out this file!, // URL(fileURLWithPath: FileManager.documentsDirectory.path()) // Replace with a real file URL // ] var shareItems: [Any] { [ textItem1, textItem2 // URL(fileURLWithPath: TinySavedItems) ] } var body: some View { VStack { TextField(enter text, text: $textItem1) .padding() TextField(enter text, text: $textItem2) .padding() Button(Share, systemImage: square.and.arrow.up) { showShareSheet = true } .sheet(isPresented: $showShareSheet) { ActivityViewController(activityItems: shareItems) } } } stru
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Mar ’26
Reply to AVAudioSession.outputVolume does not reflect system volume changes made while app is in background
I had the same problem even with Audio, AirPlay and Picture in Picture background mode enabled and with all the AVAudioSession.setActive(true) and AVAudioSession.setCategory(...) calls. We run some tests and it seems Apple made things more restrictive since iOS 18 (it was working on iOS 17.6). The only fix I found is to use the good old MPVolumeView as a substitute, but there's a catch - it's mandatory to add it to UI otherwise it will always return volume of 0. In SwiftUI it was as simple as creating a UI component: import MediaPlayer import SwiftUI struct VolumeSlider: UIViewRepresentable { private let volumeView: MPVolumeView = MPVolumeView() func makeUIView(context: Context) -> MPVolumeView { return volumeView } func updateUIView(_ view: MPVolumeView, context: Context) {} func getVolume() -> Float { if let slider = volumeView.subviews.first(where: { $0 is UISlider }) as? UISlider { return slider.value } return AVAudioSession.sharedInstance().outputVolume } } And then in your SwiftUI
Topic: Media Technologies SubTopic: Audio Tags:
Replies
Boosts
Views
Activity
Mar ’26
What steps should I follow to get started with iOS development?
Hey everyone 👋 I’m starting my journey in iOS app development coming from a Java background and I already have an app idea but want to approach things the right way so I’d love your guidance What AI tools do you recommend for coding debugging and learning Swift or SwiftUI 🤖 how do you approach app design 🎨 and where do you find UI inspiration graphics or useful resources for building apps 🚀 any tips or lessons learned would really help 🙏
Replies
1
Boosts
0
Views
76
Activity
Mar ’26
Reply to NavigationSplitView macOS
How do I get filter toolbar button near the divider like in mail app using swiftUI.
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Mar ’26
Reply to File Export from iOS - eventually import too
No, you don't need to write the data as a file to your the app’s document directory. With UIActivityViewController, you can share a piece of text, as shown in the following code example let text = This is a piece of text. let activityViewController = UIActivityViewController(activityItems: [text], applicationActivities: nil) With that, when activityViewController is presented, it shows the system-provided share UI that contains a Save to Files button, which allows you to save the text as a file to iCloud Drive. Tapping the button shows a UI that has a Save as field for you to input the file name for the taget file. To import a file, consider using SwiftUI fileImporter. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Mar ’26