Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.

All subtopics
Posts under UI Frameworks topic

Post

Replies

Boosts

Views

Created

SubscriptionStoreView showing 'The subscription is unavailable in the current storefront.' in production (StoreKit2)
I Implement a 'SubscriptionStoreView' using 'groupID' into a project (iOS is targeting 17.2 and macOS is targeting 14.1).Build/run the application locally (both production and development environments will work fine), however once the application is live on the AppStore in AppStoreConnect, SubscriptionStoreView no longer shows products and only shows 'Subscription Unavailable' and 'The subscription is unavailable in the current storefront.' - this message is shown live in production for both iOS and macOS targets. There is no log messages shown in the Console that indicate anything going wrong with StoreKit 2, but I haven't made any changes to my code and noticed this first start appearing about 5 days ago. I expect the subscription store to be visible to all users and for my products to display. My application is live on both the iOS and macOS AppStores, it passed App Review and I have users who have previously been able to subscribe and use my application, I have not pushed any new changes, so something has changed in StoreKit2 which is causing unexpected behaviour and for this error message to display. As 'SubscriptionStoreView' is a view provided by Apple, I'm really not sure on the pathway forward other than going back to StoreKit1 which I really don't want to do. Is there any further error information that can be provided on what might be causing this and how I can fix it? (I have created a feedback ticket FB13658521)
4
2
1.8k
Feb ’24
Viewbased stereoscopic drawing
Is there a way to render stereoscopic (left/right) images in a 2d plane that resides in a swiftUI view? I know this is possible in realityKit shaders, and in immersive metal composits, but is it possible via swiftUI shaders, CAMetalLayer, etc? I'd like to draw a 2d window with standard UI chrome (resize, move etc) that displays stereoscopic content on the flat plane of the window.
1
0
661
Feb ’24
TimelineView using ExplicitTimelineSchedule ignores last date?
Hi, everyone. I'm trying my first TimelineView with an explicit schedule, but my attempt – and even the simple example from the documentation – doesn't seem to work as documented. Here's what the documentation says an explicit schedule does: The timeline view updates its content on exactly the dates that you specify, until it runs out of dates, after which it stops changing. And it gives this example: let dates = [ Date(timeIntervalSinceNow: 10), // Update ten seconds from now, Date(timeIntervalSinceNow: 12), // and a few seconds later. ] struct MyView: View { var body: some View { TimelineView(.explicit(dates)) { context in Text(context.date.description) } } } There are stipulations about what the view – which always displays some version of its content body – will do given only past or future dates, but it seems clear we should expect the view in this example to redraw at least once after it appears. Here's the rest of the discussion from the documentation with my comments after testing what's stated: If the dates you provide are in the past, the timeline view updates exactly once with the last entry. That seems true, considering the "update" to be the initial draw. If you only provide dates in the future, the timeline view renders with the current date until the first date arrives. Not exactly: it looks the "date" property of the initial render is the (future) date of the first schedule entry, even though it's drawn early. When the first date does arrive, the body closure doesn't seem to be called. Only on the next date, if there is one, is it called again. If you provide one or more dates in the past and one or more in the future, the view renders the most recent past date, refreshing normally on all subsequent dates. That also seems correct, except… … that in every scenario, the final date entry seems to be ignored completely! In other words, unless all date entries are in the past, the Timeline View stops before it runs out of dates. That documented example from the start, which we expect to redraw at least once after it appears? When I test it in a Playground, it appears, but doesn't redraw at all! So, that's my main point of confusion after experimenting with TimelineView for the first time. I can achieve my own goal by appending an extra entry to my explicit schedule – even appending an entry identical to the previous "final" entry seems to work – but naturally that leaves me unclear about why I need to. If anyone can tell me what I'm not understanding, I'd be grateful.
4
2
867
Feb ’24
ScrollView with .viewAligned and .scrollPosition() not updating on orientation (size) changes
The scroll position is not updated when orientation changes in a ScrollView with .scrollTargetBehavior(.viewAligned) and .scrollPosition(). import SwiftUI struct ContentView: View { let colors: [Color] = [.red, .yellow, .cyan, .blue, .teal, .brown, .orange, .indigo] @State private var selected: Int? = 0 var body: some View { ScrollView(.horizontal) { HStack(spacing: 0) { ForEach(0..<colors.count, id: \.self) { index in Rectangle() .fill(colors[index]) .containerRelativeFrame(.horizontal) .overlay { Text(colors[index].description) } } } .scrollTargetLayout() } .scrollPosition(id: $selected) .scrollTargetBehavior(.viewAligned) } } #Preview { ContentView() } @main struct ViewAlignedScrollBugApp: App { var body: some Scene { WindowGroup { ContentView() } } } Tested on Xcode 15.3 (15E204a), iOS 17.3.1 iPhone, iOS 17.4 Simulator. Bug report FB13685677 filed with Apple.
2
1
928
Mar ’24
NSScrollView two finger drag being interrupted
I have a fairly robust MacOS application that has an NSScrollView that contains a canvas with various subviews (including web views and text views that contain scroll views), and a couple of peer views that track items in the scroll view (eg: screen space controls). Some of these views interrupt two finger scrolling. Every scroll view, and one of the peer views (essentially a stack view with buttons in it). I have written an additional bare bones application which does roughly the same thing, and my bare bones application works perfectly: Start two-finger dragging, scroll any of these other things under the cursor, I can continue to drag (and start dragging in any of those, and they drag without interfering with the parent scroll view). I have tried everything to recreate the interruption, including drag gestures attached to these various ancillary views, and I cannot figure out why dragging some of these views under the cursor interrupts two finger drag in our application, but not in my testbed. Does anyone have suggestions for how to debug this? I can see that there is a gesture recognizer in the NSScrollView hierarchy, but I don't see it in any of my gesture recognizer handling. I have breakpoints on every variation of hit testing and mouse motion, and none of them are getting hit in unexpected ways. I'm at my wit's end. Thanks.
Topic: UI Frameworks SubTopic: AppKit Tags:
3
1
746
Mar ’24
viewIsAppearing not be called in children Controllers below iOS 16?
I see viewIsAppearing is available on iOS 13 and above, but when I use it, found that the function not be called below iOS 16 https://developer.apple.com/documentation/uikit/uiviewcontroller/4195485-viewisappearing environment: Macos 14.4.1, Xcode 15.3 import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let sub = SubViewController() addChild(sub) view.addSubview(sub.view) } @available(iOS 13.0, *) override func viewIsAppearing(_ animated: Bool) { super.viewIsAppearing(animated) print("ViewController viewIsAppearing") } } class SubViewController: UIViewController { @available(iOS 13.0, *) override func viewIsAppearing(_ animated: Bool) { super.viewIsAppearing(animated) print("SubViewController viewIsAppearing") } } In iOS 15 devcice console log: ViewController viewIsAppearing iOS 16, 17: ViewController viewIsAppearing SubViewController viewIsAppearing
Topic: UI Frameworks SubTopic: UIKit Tags:
3
0
1k
Mar ’24
USSD calls with * and # dont work iOS
I have an application that needs to make a USSD call, but on some devices the * and # don't work on the dialer, on others it does. if let phoneNumber = ussdNumberTextfield.text { let encoded = "telprompt:\(phoneNumber)".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! if let url = URL(string: encoded) { if application.canOpenURL(url){ DispatchQueue.main.async { self.application.open(url, options: [:]) { success in } } } } }
5
0
1.3k
Apr ’24
Swift Chars chartYScale layout problem
I tried to narrow down the y-axis and use the clipped() to crop the excess. However, the clipped portion is too small, causing some of the chart to render above the x-axis. Is there any way to fix this, or any way to have the framework automatically set the y-axis range based on the data?
2
0
825
Apr ’24
SwiftUI: dynamicTypeSize doesn't work for items in a List
Hi, I have a List and I want to limit the dynamic text size for some of the elements in the list's row item view. I created a test view below. The ".dynamicTypeSize(.large)" restriction only works if it's applied to the List view, not if it's set for the the ContentItemView in the ForEach below. Is there a reason for this? Do I need to do something else to limit a list row to a certain size? The example only has a text field, but I want to do this for a Image with some text inside it, and I wanted to restrict that text field, but it doesn't seem to work when the view is inside a List row. Please let me know if there's a workaround for it. import SwiftUI import CoreData struct ContentView: View { @FetchRequest( sortDescriptors: [NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)], animation: .default) private var items: FetchedResults<Item> @State private var multiSelectedContacts = Set<Item.ID>() var body: some View { NavigationStack { List (selection: $multiSelectedContacts) { ForEach(items) { item in ContentItemView(item: item) } .dynamicTypeSize(.large) // <-- doesn't works } .dynamicTypeSize(.large) // <-- THIS WORKS } } } struct ContentItemView: View { @Environment(\.managedObjectContext) private var viewContext @ObservedObject var item: Item @State var presentConfirmation = false var body: some View { HStack { if let timestamp = item.timestamp, let itemNumber = item.itemNumber { Text("\(itemNumber) - \(timestamp, formatter: itemFormatter)") } } .popover(isPresented: $item.canShowPopover, content: { Text("Test Item Label") .frame(width: 100, height: 150) }) } } private let itemFormatter: DateFormatter = { let formatter = DateFormatter() formatter.dateStyle = .short formatter.timeStyle = .long return formatter }() #Preview { ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) }
2
2
654
May ’24
Simply including "@Environment(\.dismiss) ..." causes multiple calls to a view's body
When I run the code below, the trace, "Called", is shown 3-4 times initially. If I click on a color row, the trace shows 9 times. Why is that? If I comment out the line, @Environment(\.dismiss) private var dismiss, the trace shows only 1 time, as expected. I've read a number of reports regarding dismiss() which seems to be very brittle. It often causes an infinite loop. But I need to dismiss a view. Its older counterpart, @Environment(\.presentationMode), seems to cause infinite loop at times. Are there other ways to dismiss a view without suffering these issues? struct TestNavigationLink: View { @Environment(\.dismiss) private var dismiss var body: some View { let _ = print("Called") NavigationStack { List { NavigationLink("Mint") { ColorDetail(color: .mint) } } .navigationTitle("Colors") } } // body struct ColorDetail: View { var color: Color var body: some View { color.navigationTitle(color.description) } } }
2
1
720
May ’24
iOS app crash with UIKitcore - UIAlertController
I have recently submitted a new app version to the Appstore with Xcode 15.0. Unfortunately, I have started to see the below crash in the Xcode organiser &gt; Crashes section occurring for more number of times. UIKitCore: +[UIAlertController _alertControllerContainedInViewController:] + 160 The exception trace is not leading to main() function but not pointing to any of the code line. I had used UIAlertController in the past versions to show the alerts but there is no code written in the current version code related to UIAlertController. Only from the latest version, this kind of crash started to surface. In the latest release, We have added a third party SDK and while implementing the SDK, we had added the Location and Bluetooth Permissions in Info.plist file. But as we don't want to use/track the Location and Bluetooth details from the app, the SDK team has disabled the Location and Bluetooth settings to not reflect in the tracked data. Is this behaviour creating any conflict with the UIAlertController and logging the crash? Because by default the OS tries to show the alert when the permissions exist in the plist file, but the alert will not come as the service is disabled on the SDK server settings. Is this creating any conflict and logging the crash. Please extend your help.
3
0
904
May ’24
App crashes in CGFontStrikeRelease
This crash has been troubling us for a long time. We have this crash report in every release of our App, but can't reproduce it. Here is part of the crash info: Incident Identifier: xxxx Hardware Model: iPhone13,3 Process: MyApp [34550] Path: /private/var/containers/Bundle/Application/xxxx/MyApp.app/MyApp Identifier: xxx.xxx Version: xxx (296) AppStoreTools: 15F31c AppVariant: 1:iPhone13,3:15 Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] Coalition: xxx.xxx [466] Date/Time: 2024-05-19 13:59:10.9716 +0800 Launch Time: 2024-05-19 12:18:24.8753 +0800 OS Version: iPhone OS 16.6.1 (20G81) Release Type: User Baseband Version: 3.80.01 Report Version: 104 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x322e323400000000 -> 0x0000003400000000 (possible pointer authentication failure) Exception Codes: 0x0000000000000001, 0x322e323400000000 VM Region Info: 0x3400000000 is in 0x1000000000-0x7000000000; bytes after start: 154618822656 bytes before end: 257698037759 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL commpage (reserved) fc0000000-1000000000 [ 1.0G] ---/--- SM=NUL ...(unallocated) ---> GPU Carveout (reserved) 1000000000-7000000000 [384.0G] ---/--- SM=NUL ...(unallocated) UNUSED SPACE AT END Triggered by Thread: 0 Thread 0 name: Thread 0 Crashed: 0 CoreGraphics 0x00000001bd1d0780 CGFontStrikeRelease + 76 (CGFontStrike.c:126) 1 CoreGraphics 0x00000001bd1dd0cc CGGlyphBuilderUnlockBitmaps + 476 (CGGlyphBuilder.cc:113) 2 CoreGraphics 0x00000001bd1eb8c8 render_glyphs + 412 (RIPContextDrawGlyphs.c:127) 3 CoreGraphics 0x00000001bd202ea4 draw_glyph_bitmaps + 1132 (RIPContextDrawGlyphs.c:210) 4 CoreGraphics 0x00000001bd21a0ec ripc_DrawGlyphs + 1320 (RIPContextDrawGlyphs.c:558) 5 CoreGraphics 0x00000001bd1d26d8 CG::DisplayList::executeEntries(std::__1::__wrap_iter<std::__1::unique_ptr<CG::DisplayListEntry const, std::__1::default_delete<CG::DisplayListEntry const> >*>, std::__1::__wrap_iter<std::__1::uniq... + 5852 (DisplayList.cpp:1657) 6 CoreGraphics 0x00000001bd1c86a8 CGDisplayListDrawInContextDelegate + 268 (DisplayList.cpp:2151) 7 QuartzCore 0x00000001bcc797d4 CABackingStoreUpdate_ + 468 (CABackingStore.cpp:1388) 8 QuartzCore 0x00000001bccf0c34 invocation function for block in CA::Layer::display_() + 64 (CALayer.mm:9699) 9 QuartzCore 0x00000001bcc78d54 -[CALayer _display] + 1720 (CALayer.mm:9732) 10 QuartzCore 0x00000001bcc785b4 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 412 (CALayer.mm:2521) 11 QuartzCore 0x00000001bcc898d8 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 444 (CAContextInternal.mm:2714) 12 QuartzCore 0x00000001bccb8e80 CA::Transaction::commit() + 648 (CATransactionInternal.mm:432) 13 QuartzCore 0x00000001bcca2df0 CA::Transaction::flush_as_runloop_observer(bool) + 88 (CATransactionInternal.mm:940) 14 UIKitCore 0x00000001bdca34d0 _UIApplicationFlushCATransaction + 52 (UIApplication.m:3286) 15 UIKitCore 0x00000001bddf3d94 _UIUpdateSequenceRun + 84 (_UIUpdateSequence.mm:114) 16 UIKitCore 0x00000001be458894 schedulerStepScheduledMainSection + 144 (_UIUpdateScheduler.m:1015) 17 UIKitCore 0x00000001be457df0 runloopSourceCallback + 92 (_UIUpdateScheduler.m:1164) 18 CoreFoundation 0x00000001bb80a128 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1957) 19 CoreFoundation 0x00000001bb8167b4 __CFRunLoopDoSource0 + 176 (CFRunLoop.c:2001) 20 CoreFoundation 0x00000001bb79b5e8 __CFRunLoopDoSources0 + 244 (CFRunLoop.c:2038) 21 CoreFoundation 0x00000001bb7b10d4 __CFRunLoopRun + 828 (CFRunLoop.c:2953) 22 CoreFoundation 0x00000001bb7b63ec CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418) 23 GraphicsServices 0x00000001f6ccc35c GSEventRunModal + 164 (GSEvent.c:2196) 24 UIKitCore 0x00000001bdb42f58 -[UIApplication _run] + 888 (UIApplication.m:3782) 25 UIKitCore 0x00000001bdb42bbc UIApplicationMain + 340 (UIApplication.m:5372) 26 MyApp 0x000000010468f978 main + 80 (main.m:15) 27 dyld 0x00000001dace8dec start + 2220 (dyldMain.cpp:1165) Thread 1 name: Thread 1: 0 libsystem_kernel.dylib 0x00000001fa6f6ca4 mach_msg2_trap + 8 (:-1) 1 libsystem_kernel.dylib 0x00000001fa709b74 mach_msg2_internal + 80 (mach_msg.c:201) 2 libsystem_kernel.dylib 0x00000001fa709e4c mach_msg_overwrite + 540 (mach_msg.c:0) 3 libsystem_kernel.dylib 0x00000001fa6f71e8 mach_msg + 24 (mach_msg.c:323) 4 CoreFoundation 0x00000001bb7b0024 __CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2622) 5 CoreFoundation 0x00000001bb7b1250 __CFRunLoopRun + 1208 (CFRunLoop.c:3005) 6 CoreFoundation 0x00000001bb7b63ec CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418) 7 Foundation 0x00000001b5a2efb4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212 (NSRunLoop.m:373) 8 Foundation 0x00000001b5a2ee9c -[NSRunLoop(NSRunLoop) runUntilDate:] + 64 (NSRunLoop.m:420) 9 UIKitCore 0x00000001bdc75cc8 -[UIEventFetcher threadMain] + 416 (UIEventFetcher.m:1376) 10 Foundation 0x00000001b5a48524 __NSThread__start__ + 716 (NSThread.m:963) 11 libsystem_pthread.dylib 0x000000021b5766b8 _pthread_start + 148 (pthread.c:893) 12 libsystem_pthread.dylib 0x000000021b575b88 thread_start + 8 (:-1) Thread 2: 0 libsystem_kernel.dylib 0x00000001fa6f7164 __semwait_signal + 8 (:-1) 1 libsystem_c.dylib 0x00000001c2c50888 nanosleep + 220 (nanosleep.c:104) 2 libsystem_c.dylib 0x00000001c2c61b1c sleep + 52 (sleep.c:62) 3 MyApp 0x00000001075ccb14 -[UTDCacheManager synchronizeData] + 104 (UTDCacheManager.m:133) 4 Foundation 0x00000001b5a48524 __NSThread__start__ + 716 (NSThread.m:963) 5 libsystem_pthread.dylib 0x000000021b5766b8 _pthread_start + 148 (pthread.c:893) 6 libsystem_pthread.dylib 0x000000021b575b88 thread_start + 8 (:-1)
4
0
1k
May ’24
[iOSAppOnMac] ShareKit: Crashes in SHKItemIsPDF() or -[SHKSaveToFilesSharingService saveFileURL:completion:]
I have a custom document-based iOS app that also runs on macOS. After implementing -activityItemsConfiguration to enable sharing from the context menu, I found that the app crashes on macOS when selecting Share… from the context menu and then selecting Save (i.e. Save to Files under iOS). This problem does not occur on iOS, which behaves correctly. - (id<UIActivityItemsConfigurationReading>)activityItemsConfiguration { NSItemProvider * provider = [[NSItemProvider alloc] initWithContentsOfURL:self.document.presentedItemURL]; UIActivityItemsConfiguration * configuration = [UIActivityItemsConfiguration activityItemsConfigurationWithItemProviders:@[ provider ]]; // XXX crashes with com.apple.share.System.SaveToFiles return configuration; } Additionally, I found that to even reach this crash, the workaround implemented in the NSItemProvider (FBxxx) category of the sample project is needed. Without this, the app will crash much earlier, due to SHKItemIsPDF() erroneously invoking -pathExtension on an NSItemProvider. This appears to be a second bug in Apple’s private ShareKit framework. #import <UniformTypeIdentifiers/UniformTypeIdentifiers.h> @implementation NSItemProvider (FBxxx) // XXX SHKItemIsPDF() invokes -pathExtension on an NSItemProvider (when running under macOS, anyway) -> crash - (NSString *)pathExtension { return self.registeredContentTypes.firstObject.preferredFilenameExtension; } @end Again, this all works fine on iOS (17.5) but crashes when the exact same app build is running on macOS (14.5). I believe these bugs are Apple's. Any idea how to avoid the crash? Is there a way to disable the "Save to Files" option in the sharing popup? I filed FB13819800 with a sample project that demonstrates the crash on macOS. I was going to file a TSI to get this resolved, but I see that DTS is not responding to tech support incidents until after WWDC.
Topic: UI Frameworks SubTopic: UIKit
8
3
729
Jun ’24
SwiftData with shared and private containers
I was hoping for an update of SwiftData which adopted the use of shared and public CloudKit containers, in the same way it does for the private CloudKit container. So firstly, a big request to any Apple devs reading, for this to be a thing! Secondly, what would be a sensible way of adding a shared container in CloudKit to an existing app that is already using SwiftData? Would it be possible to use the new DataStore method to manage CloudKit syncing with a public or shared container?
12
18
4.1k
Jun ’24
macOS SwiftUI Sheets are no longer resizable (Xcode 16 beta2)
For whatever reason SwiftUI sheets don't seem to be resizable anymore. The exact same code/project produces resizable Sheets in XCode 15.4 but unresizable ones with Swift included in Xcode 16 beta 2. Tried explicitly providing .fixedSize(horizontal false, vertical: false) everywhere humanly possible hoping for a fix but sheets are still stuck at an awkward size (turns out be the minWidth/minHeight if I provide in .frame).
7
1
2.8k
Jun ’24
SubscriptionStoreView showing 'The subscription is unavailable in the current storefront.' in production (StoreKit2)
I Implement a 'SubscriptionStoreView' using 'groupID' into a project (iOS is targeting 17.2 and macOS is targeting 14.1).Build/run the application locally (both production and development environments will work fine), however once the application is live on the AppStore in AppStoreConnect, SubscriptionStoreView no longer shows products and only shows 'Subscription Unavailable' and 'The subscription is unavailable in the current storefront.' - this message is shown live in production for both iOS and macOS targets. There is no log messages shown in the Console that indicate anything going wrong with StoreKit 2, but I haven't made any changes to my code and noticed this first start appearing about 5 days ago. I expect the subscription store to be visible to all users and for my products to display. My application is live on both the iOS and macOS AppStores, it passed App Review and I have users who have previously been able to subscribe and use my application, I have not pushed any new changes, so something has changed in StoreKit2 which is causing unexpected behaviour and for this error message to display. As 'SubscriptionStoreView' is a view provided by Apple, I'm really not sure on the pathway forward other than going back to StoreKit1 which I really don't want to do. Is there any further error information that can be provided on what might be causing this and how I can fix it? (I have created a feedback ticket FB13658521)
Replies
4
Boosts
2
Views
1.8k
Activity
Feb ’24
Viewbased stereoscopic drawing
Is there a way to render stereoscopic (left/right) images in a 2d plane that resides in a swiftUI view? I know this is possible in realityKit shaders, and in immersive metal composits, but is it possible via swiftUI shaders, CAMetalLayer, etc? I'd like to draw a 2d window with standard UI chrome (resize, move etc) that displays stereoscopic content on the flat plane of the window.
Replies
1
Boosts
0
Views
661
Activity
Feb ’24
TimelineView using ExplicitTimelineSchedule ignores last date?
Hi, everyone. I'm trying my first TimelineView with an explicit schedule, but my attempt – and even the simple example from the documentation – doesn't seem to work as documented. Here's what the documentation says an explicit schedule does: The timeline view updates its content on exactly the dates that you specify, until it runs out of dates, after which it stops changing. And it gives this example: let dates = [ Date(timeIntervalSinceNow: 10), // Update ten seconds from now, Date(timeIntervalSinceNow: 12), // and a few seconds later. ] struct MyView: View { var body: some View { TimelineView(.explicit(dates)) { context in Text(context.date.description) } } } There are stipulations about what the view – which always displays some version of its content body – will do given only past or future dates, but it seems clear we should expect the view in this example to redraw at least once after it appears. Here's the rest of the discussion from the documentation with my comments after testing what's stated: If the dates you provide are in the past, the timeline view updates exactly once with the last entry. That seems true, considering the "update" to be the initial draw. If you only provide dates in the future, the timeline view renders with the current date until the first date arrives. Not exactly: it looks the "date" property of the initial render is the (future) date of the first schedule entry, even though it's drawn early. When the first date does arrive, the body closure doesn't seem to be called. Only on the next date, if there is one, is it called again. If you provide one or more dates in the past and one or more in the future, the view renders the most recent past date, refreshing normally on all subsequent dates. That also seems correct, except… … that in every scenario, the final date entry seems to be ignored completely! In other words, unless all date entries are in the past, the Timeline View stops before it runs out of dates. That documented example from the start, which we expect to redraw at least once after it appears? When I test it in a Playground, it appears, but doesn't redraw at all! So, that's my main point of confusion after experimenting with TimelineView for the first time. I can achieve my own goal by appending an extra entry to my explicit schedule – even appending an entry identical to the previous "final" entry seems to work – but naturally that leaves me unclear about why I need to. If anyone can tell me what I'm not understanding, I'd be grateful.
Replies
4
Boosts
2
Views
867
Activity
Feb ’24
ScrollView with .viewAligned and .scrollPosition() not updating on orientation (size) changes
The scroll position is not updated when orientation changes in a ScrollView with .scrollTargetBehavior(.viewAligned) and .scrollPosition(). import SwiftUI struct ContentView: View { let colors: [Color] = [.red, .yellow, .cyan, .blue, .teal, .brown, .orange, .indigo] @State private var selected: Int? = 0 var body: some View { ScrollView(.horizontal) { HStack(spacing: 0) { ForEach(0..<colors.count, id: \.self) { index in Rectangle() .fill(colors[index]) .containerRelativeFrame(.horizontal) .overlay { Text(colors[index].description) } } } .scrollTargetLayout() } .scrollPosition(id: $selected) .scrollTargetBehavior(.viewAligned) } } #Preview { ContentView() } @main struct ViewAlignedScrollBugApp: App { var body: some Scene { WindowGroup { ContentView() } } } Tested on Xcode 15.3 (15E204a), iOS 17.3.1 iPhone, iOS 17.4 Simulator. Bug report FB13685677 filed with Apple.
Replies
2
Boosts
1
Views
928
Activity
Mar ’24
are assets/gloves/LeftGlove_v001.usdz & RightGlove avaliable
in this great talk https://developer.apple.com/videos/play/wwdc2023/10111/ the code references usdz models to replace hands. e.g assets/gloves/LeftGlove_v001.usdz. Are these models available to download to explain rigging and how to make hand models (ideally in Blender )
Replies
4
Boosts
0
Views
663
Activity
Mar ’24
NSScrollView two finger drag being interrupted
I have a fairly robust MacOS application that has an NSScrollView that contains a canvas with various subviews (including web views and text views that contain scroll views), and a couple of peer views that track items in the scroll view (eg: screen space controls). Some of these views interrupt two finger scrolling. Every scroll view, and one of the peer views (essentially a stack view with buttons in it). I have written an additional bare bones application which does roughly the same thing, and my bare bones application works perfectly: Start two-finger dragging, scroll any of these other things under the cursor, I can continue to drag (and start dragging in any of those, and they drag without interfering with the parent scroll view). I have tried everything to recreate the interruption, including drag gestures attached to these various ancillary views, and I cannot figure out why dragging some of these views under the cursor interrupts two finger drag in our application, but not in my testbed. Does anyone have suggestions for how to debug this? I can see that there is a gesture recognizer in the NSScrollView hierarchy, but I don't see it in any of my gesture recognizer handling. I have breakpoints on every variation of hit testing and mouse motion, and none of them are getting hit in unexpected ways. I'm at my wit's end. Thanks.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
3
Boosts
1
Views
746
Activity
Mar ’24
viewIsAppearing not be called in children Controllers below iOS 16?
I see viewIsAppearing is available on iOS 13 and above, but when I use it, found that the function not be called below iOS 16 https://developer.apple.com/documentation/uikit/uiviewcontroller/4195485-viewisappearing environment: Macos 14.4.1, Xcode 15.3 import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let sub = SubViewController() addChild(sub) view.addSubview(sub.view) } @available(iOS 13.0, *) override func viewIsAppearing(_ animated: Bool) { super.viewIsAppearing(animated) print("ViewController viewIsAppearing") } } class SubViewController: UIViewController { @available(iOS 13.0, *) override func viewIsAppearing(_ animated: Bool) { super.viewIsAppearing(animated) print("SubViewController viewIsAppearing") } } In iOS 15 devcice console log: ViewController viewIsAppearing iOS 16, 17: ViewController viewIsAppearing SubViewController viewIsAppearing
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
3
Boosts
0
Views
1k
Activity
Mar ’24
USSD calls with * and # dont work iOS
I have an application that needs to make a USSD call, but on some devices the * and # don't work on the dialer, on others it does. if let phoneNumber = ussdNumberTextfield.text { let encoded = "telprompt:\(phoneNumber)".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! if let url = URL(string: encoded) { if application.canOpenURL(url){ DispatchQueue.main.async { self.application.open(url, options: [:]) { success in } } } } }
Replies
5
Boosts
0
Views
1.3k
Activity
Apr ’24
Swift Chars chartYScale layout problem
I tried to narrow down the y-axis and use the clipped() to crop the excess. However, the clipped portion is too small, causing some of the chart to render above the x-axis. Is there any way to fix this, or any way to have the framework automatically set the y-axis range based on the data?
Replies
2
Boosts
0
Views
825
Activity
Apr ’24
Link, SwiftUI bug?, button trait identified on VoiceOver for a link.
In SwiftUI, a link is identified as both a button and link, this is during when running with VoiceOver. I know you can remove the button trait using .accessibilityRemoveTraits. However, I am sure there is a reason to it. Can somebody explain if it is genuinely a bug.
Replies
1
Boosts
1
Views
309
Activity
Apr ’24
NavigationStack with clear background in VisionOS
how to get a clear background with navigationstack in visionOS app?
Replies
1
Boosts
0
Views
332
Activity
May ’24
SwiftUI: dynamicTypeSize doesn't work for items in a List
Hi, I have a List and I want to limit the dynamic text size for some of the elements in the list's row item view. I created a test view below. The ".dynamicTypeSize(.large)" restriction only works if it's applied to the List view, not if it's set for the the ContentItemView in the ForEach below. Is there a reason for this? Do I need to do something else to limit a list row to a certain size? The example only has a text field, but I want to do this for a Image with some text inside it, and I wanted to restrict that text field, but it doesn't seem to work when the view is inside a List row. Please let me know if there's a workaround for it. import SwiftUI import CoreData struct ContentView: View { @FetchRequest( sortDescriptors: [NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)], animation: .default) private var items: FetchedResults<Item> @State private var multiSelectedContacts = Set<Item.ID>() var body: some View { NavigationStack { List (selection: $multiSelectedContacts) { ForEach(items) { item in ContentItemView(item: item) } .dynamicTypeSize(.large) // <-- doesn't works } .dynamicTypeSize(.large) // <-- THIS WORKS } } } struct ContentItemView: View { @Environment(\.managedObjectContext) private var viewContext @ObservedObject var item: Item @State var presentConfirmation = false var body: some View { HStack { if let timestamp = item.timestamp, let itemNumber = item.itemNumber { Text("\(itemNumber) - \(timestamp, formatter: itemFormatter)") } } .popover(isPresented: $item.canShowPopover, content: { Text("Test Item Label") .frame(width: 100, height: 150) }) } } private let itemFormatter: DateFormatter = { let formatter = DateFormatter() formatter.dateStyle = .short formatter.timeStyle = .long return formatter }() #Preview { ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) }
Replies
2
Boosts
2
Views
654
Activity
May ’24
Simply including "@Environment(\.dismiss) ..." causes multiple calls to a view's body
When I run the code below, the trace, "Called", is shown 3-4 times initially. If I click on a color row, the trace shows 9 times. Why is that? If I comment out the line, @Environment(\.dismiss) private var dismiss, the trace shows only 1 time, as expected. I've read a number of reports regarding dismiss() which seems to be very brittle. It often causes an infinite loop. But I need to dismiss a view. Its older counterpart, @Environment(\.presentationMode), seems to cause infinite loop at times. Are there other ways to dismiss a view without suffering these issues? struct TestNavigationLink: View { @Environment(\.dismiss) private var dismiss var body: some View { let _ = print("Called") NavigationStack { List { NavigationLink("Mint") { ColorDetail(color: .mint) } } .navigationTitle("Colors") } } // body struct ColorDetail: View { var color: Color var body: some View { color.navigationTitle(color.description) } } }
Replies
2
Boosts
1
Views
720
Activity
May ’24
iOS app crash with UIKitcore - UIAlertController
I have recently submitted a new app version to the Appstore with Xcode 15.0. Unfortunately, I have started to see the below crash in the Xcode organiser &gt; Crashes section occurring for more number of times. UIKitCore: +[UIAlertController _alertControllerContainedInViewController:] + 160 The exception trace is not leading to main() function but not pointing to any of the code line. I had used UIAlertController in the past versions to show the alerts but there is no code written in the current version code related to UIAlertController. Only from the latest version, this kind of crash started to surface. In the latest release, We have added a third party SDK and while implementing the SDK, we had added the Location and Bluetooth Permissions in Info.plist file. But as we don't want to use/track the Location and Bluetooth details from the app, the SDK team has disabled the Location and Bluetooth settings to not reflect in the tracked data. Is this behaviour creating any conflict with the UIAlertController and logging the crash? Because by default the OS tries to show the alert when the permissions exist in the plist file, but the alert will not come as the service is disabled on the SDK server settings. Is this creating any conflict and logging the crash. Please extend your help.
Replies
3
Boosts
0
Views
904
Activity
May ’24
App crashes in CGFontStrikeRelease
This crash has been troubling us for a long time. We have this crash report in every release of our App, but can't reproduce it. Here is part of the crash info: Incident Identifier: xxxx Hardware Model: iPhone13,3 Process: MyApp [34550] Path: /private/var/containers/Bundle/Application/xxxx/MyApp.app/MyApp Identifier: xxx.xxx Version: xxx (296) AppStoreTools: 15F31c AppVariant: 1:iPhone13,3:15 Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] Coalition: xxx.xxx [466] Date/Time: 2024-05-19 13:59:10.9716 +0800 Launch Time: 2024-05-19 12:18:24.8753 +0800 OS Version: iPhone OS 16.6.1 (20G81) Release Type: User Baseband Version: 3.80.01 Report Version: 104 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x322e323400000000 -> 0x0000003400000000 (possible pointer authentication failure) Exception Codes: 0x0000000000000001, 0x322e323400000000 VM Region Info: 0x3400000000 is in 0x1000000000-0x7000000000; bytes after start: 154618822656 bytes before end: 257698037759 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL commpage (reserved) fc0000000-1000000000 [ 1.0G] ---/--- SM=NUL ...(unallocated) ---> GPU Carveout (reserved) 1000000000-7000000000 [384.0G] ---/--- SM=NUL ...(unallocated) UNUSED SPACE AT END Triggered by Thread: 0 Thread 0 name: Thread 0 Crashed: 0 CoreGraphics 0x00000001bd1d0780 CGFontStrikeRelease + 76 (CGFontStrike.c:126) 1 CoreGraphics 0x00000001bd1dd0cc CGGlyphBuilderUnlockBitmaps + 476 (CGGlyphBuilder.cc:113) 2 CoreGraphics 0x00000001bd1eb8c8 render_glyphs + 412 (RIPContextDrawGlyphs.c:127) 3 CoreGraphics 0x00000001bd202ea4 draw_glyph_bitmaps + 1132 (RIPContextDrawGlyphs.c:210) 4 CoreGraphics 0x00000001bd21a0ec ripc_DrawGlyphs + 1320 (RIPContextDrawGlyphs.c:558) 5 CoreGraphics 0x00000001bd1d26d8 CG::DisplayList::executeEntries(std::__1::__wrap_iter<std::__1::unique_ptr<CG::DisplayListEntry const, std::__1::default_delete<CG::DisplayListEntry const> >*>, std::__1::__wrap_iter<std::__1::uniq... + 5852 (DisplayList.cpp:1657) 6 CoreGraphics 0x00000001bd1c86a8 CGDisplayListDrawInContextDelegate + 268 (DisplayList.cpp:2151) 7 QuartzCore 0x00000001bcc797d4 CABackingStoreUpdate_ + 468 (CABackingStore.cpp:1388) 8 QuartzCore 0x00000001bccf0c34 invocation function for block in CA::Layer::display_() + 64 (CALayer.mm:9699) 9 QuartzCore 0x00000001bcc78d54 -[CALayer _display] + 1720 (CALayer.mm:9732) 10 QuartzCore 0x00000001bcc785b4 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 412 (CALayer.mm:2521) 11 QuartzCore 0x00000001bcc898d8 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 444 (CAContextInternal.mm:2714) 12 QuartzCore 0x00000001bccb8e80 CA::Transaction::commit() + 648 (CATransactionInternal.mm:432) 13 QuartzCore 0x00000001bcca2df0 CA::Transaction::flush_as_runloop_observer(bool) + 88 (CATransactionInternal.mm:940) 14 UIKitCore 0x00000001bdca34d0 _UIApplicationFlushCATransaction + 52 (UIApplication.m:3286) 15 UIKitCore 0x00000001bddf3d94 _UIUpdateSequenceRun + 84 (_UIUpdateSequence.mm:114) 16 UIKitCore 0x00000001be458894 schedulerStepScheduledMainSection + 144 (_UIUpdateScheduler.m:1015) 17 UIKitCore 0x00000001be457df0 runloopSourceCallback + 92 (_UIUpdateScheduler.m:1164) 18 CoreFoundation 0x00000001bb80a128 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1957) 19 CoreFoundation 0x00000001bb8167b4 __CFRunLoopDoSource0 + 176 (CFRunLoop.c:2001) 20 CoreFoundation 0x00000001bb79b5e8 __CFRunLoopDoSources0 + 244 (CFRunLoop.c:2038) 21 CoreFoundation 0x00000001bb7b10d4 __CFRunLoopRun + 828 (CFRunLoop.c:2953) 22 CoreFoundation 0x00000001bb7b63ec CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418) 23 GraphicsServices 0x00000001f6ccc35c GSEventRunModal + 164 (GSEvent.c:2196) 24 UIKitCore 0x00000001bdb42f58 -[UIApplication _run] + 888 (UIApplication.m:3782) 25 UIKitCore 0x00000001bdb42bbc UIApplicationMain + 340 (UIApplication.m:5372) 26 MyApp 0x000000010468f978 main + 80 (main.m:15) 27 dyld 0x00000001dace8dec start + 2220 (dyldMain.cpp:1165) Thread 1 name: Thread 1: 0 libsystem_kernel.dylib 0x00000001fa6f6ca4 mach_msg2_trap + 8 (:-1) 1 libsystem_kernel.dylib 0x00000001fa709b74 mach_msg2_internal + 80 (mach_msg.c:201) 2 libsystem_kernel.dylib 0x00000001fa709e4c mach_msg_overwrite + 540 (mach_msg.c:0) 3 libsystem_kernel.dylib 0x00000001fa6f71e8 mach_msg + 24 (mach_msg.c:323) 4 CoreFoundation 0x00000001bb7b0024 __CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2622) 5 CoreFoundation 0x00000001bb7b1250 __CFRunLoopRun + 1208 (CFRunLoop.c:3005) 6 CoreFoundation 0x00000001bb7b63ec CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418) 7 Foundation 0x00000001b5a2efb4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212 (NSRunLoop.m:373) 8 Foundation 0x00000001b5a2ee9c -[NSRunLoop(NSRunLoop) runUntilDate:] + 64 (NSRunLoop.m:420) 9 UIKitCore 0x00000001bdc75cc8 -[UIEventFetcher threadMain] + 416 (UIEventFetcher.m:1376) 10 Foundation 0x00000001b5a48524 __NSThread__start__ + 716 (NSThread.m:963) 11 libsystem_pthread.dylib 0x000000021b5766b8 _pthread_start + 148 (pthread.c:893) 12 libsystem_pthread.dylib 0x000000021b575b88 thread_start + 8 (:-1) Thread 2: 0 libsystem_kernel.dylib 0x00000001fa6f7164 __semwait_signal + 8 (:-1) 1 libsystem_c.dylib 0x00000001c2c50888 nanosleep + 220 (nanosleep.c:104) 2 libsystem_c.dylib 0x00000001c2c61b1c sleep + 52 (sleep.c:62) 3 MyApp 0x00000001075ccb14 -[UTDCacheManager synchronizeData] + 104 (UTDCacheManager.m:133) 4 Foundation 0x00000001b5a48524 __NSThread__start__ + 716 (NSThread.m:963) 5 libsystem_pthread.dylib 0x000000021b5766b8 _pthread_start + 148 (pthread.c:893) 6 libsystem_pthread.dylib 0x000000021b575b88 thread_start + 8 (:-1)
Replies
4
Boosts
0
Views
1k
Activity
May ’24
[iOSAppOnMac] ShareKit: Crashes in SHKItemIsPDF() or -[SHKSaveToFilesSharingService saveFileURL:completion:]
I have a custom document-based iOS app that also runs on macOS. After implementing -activityItemsConfiguration to enable sharing from the context menu, I found that the app crashes on macOS when selecting Share… from the context menu and then selecting Save (i.e. Save to Files under iOS). This problem does not occur on iOS, which behaves correctly. - (id<UIActivityItemsConfigurationReading>)activityItemsConfiguration { NSItemProvider * provider = [[NSItemProvider alloc] initWithContentsOfURL:self.document.presentedItemURL]; UIActivityItemsConfiguration * configuration = [UIActivityItemsConfiguration activityItemsConfigurationWithItemProviders:@[ provider ]]; // XXX crashes with com.apple.share.System.SaveToFiles return configuration; } Additionally, I found that to even reach this crash, the workaround implemented in the NSItemProvider (FBxxx) category of the sample project is needed. Without this, the app will crash much earlier, due to SHKItemIsPDF() erroneously invoking -pathExtension on an NSItemProvider. This appears to be a second bug in Apple’s private ShareKit framework. #import <UniformTypeIdentifiers/UniformTypeIdentifiers.h> @implementation NSItemProvider (FBxxx) // XXX SHKItemIsPDF() invokes -pathExtension on an NSItemProvider (when running under macOS, anyway) -> crash - (NSString *)pathExtension { return self.registeredContentTypes.firstObject.preferredFilenameExtension; } @end Again, this all works fine on iOS (17.5) but crashes when the exact same app build is running on macOS (14.5). I believe these bugs are Apple's. Any idea how to avoid the crash? Is there a way to disable the "Save to Files" option in the sharing popup? I filed FB13819800 with a sample project that demonstrates the crash on macOS. I was going to file a TSI to get this resolved, but I see that DTS is not responding to tech support incidents until after WWDC.
Topic: UI Frameworks SubTopic: UIKit
Replies
8
Boosts
3
Views
729
Activity
Jun ’24
SwiftData with shared and private containers
I was hoping for an update of SwiftData which adopted the use of shared and public CloudKit containers, in the same way it does for the private CloudKit container. So firstly, a big request to any Apple devs reading, for this to be a thing! Secondly, what would be a sensible way of adding a shared container in CloudKit to an existing app that is already using SwiftData? Would it be possible to use the new DataStore method to manage CloudKit syncing with a public or shared container?
Replies
12
Boosts
18
Views
4.1k
Activity
Jun ’24
macOS SwiftUI Sheets are no longer resizable (Xcode 16 beta2)
For whatever reason SwiftUI sheets don't seem to be resizable anymore. The exact same code/project produces resizable Sheets in XCode 15.4 but unresizable ones with Swift included in Xcode 16 beta 2. Tried explicitly providing .fixedSize(horizontal false, vertical: false) everywhere humanly possible hoping for a fix but sheets are still stuck at an awkward size (turns out be the minWidth/minHeight if I provide in .frame).
Replies
7
Boosts
1
Views
2.8k
Activity
Jun ’24
onScrollPhaseChange doesn't get called when using List
Hi, I can't get onScrollPhaseChange to fire when using a List. It works as expected when using a ScollView and LazyVStack. Interestingly, onScrollGeometryChange gets called as expected for both List and ScrollView. Has anyone successfully used onScrollPhaseChange with a List?
Replies
6
Boosts
1
Views
881
Activity
Jul ’24
Live Activity Blanks out when lock screen sleeps.
I have a live activity, that works fine when the Lock Screen showing, but as soon as it "sleeps" dims down for always on display, everything in the widget disappears and an Activity Indicator(spinner), displays in its place, but non-animating.
Replies
4
Boosts
0
Views
1k
Activity
Jul ’24