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

Activity

How to skip library check in framework
I have build a framework name is HansTranslation.framework for iOS 18 only, because it is include Translation. My app is okay when I call this framework on iOS 18 device, but it is crash on iOS 17.6. below is error info: Symbol not found: _$s7SwiftUI4ViewP013_Translation_aB0E15translationTask_6actionQr0D00D7SessionC13C onfigurationVSg_yAIYactF Referenced from: <4E09A66F-7D9E-3793-A2D6-1BE167EAD3F5> /private/var/containers/Bundle/Application/90A1EF03-09DA-43B5-8946-8186CF9CC804/B uild SRT.app/Frameworks/HansTranslation.framework/HansTranslation (built for ios 18.0 which is newer than running OS) <8F146BA4-EBE8-32C5-9CD8-E30077AD8088> /System/Library/Frameworks/_Translation_SwiftUI. framework/_Translation_SwiftUI I known that iOS 17.6 is NOT include "Translation_SwiftUI. framework", so there is crash. I have notice that don't call this framework when iOS version less than iOS 18, my code control like API_AVAILABLE(ios(18.0)) or @available(iOS 18.0, *)). I try that set "Build Phases" -> Embed Framework -> Copy only when installing -> ON, it is okay on iOS 17.6, but it is not work on iOS 18. My framework in here: https://github.com/MingJieHan/HansTranslation My question that how to do? first way that change option for HansTranslation.framework, let it not link Translation_SwiftUI automatically, not success. second way that change my app option, let it not check library, I don't know how to do next step. please help me or give me some idea for those. Thanks.
Topic: UI Frameworks SubTopic: General
1
0
324
Oct ’24
users Widgets disappear!!! Xcode 16
Some users have reported that the app's widgets have disappeared after we updated to the latest Xcode for iOS 18 development. They are unable to find our app in the widget search, which prevents them from re-adding the widget. We were unable to reproduce this issue on our own devices during testing. Could this be a system bug? Have others encountered a similar issue?
11
8
1.8k
Oct ’24
iOS widget crashing in body getter with -[NSTaggedPointerString identifier]: unrecognized selector sent to instance
Here is the code where the crash occurs var body: some WidgetConfiguration { IntentConfiguration(kind: WidgetKind, intent: ConfigurationIntent.self, provider: provider) { entry in // Parse config if let config = entry.configuration { if let fg = config.foreground, let fgColorId = fg.identifier, <---- let fgColors = AppSettings.sharedInstance()?.object(forKey: kWidgetForeground) as? [String:String], let fgColor = fgColors[fgColorId] { theme.textColor = Color.init(UIColor.fromHex(fgColor)) theme.iconColor = Color.init(UIColor.fromHex(fgColor)) } else { theme.textColor = .white//Color.primary theme.iconColor = .white//Color.primary } configuration is INIntent with foreground var which is INObject but some times it seems its not... and instead its NSTaggedPointerString unless I'm missing something here.
3
0
534
Oct ’24
SwiftUI conditional modifier depending on OS type and version
This app may run on MacOS or iOS. I want to use windowResizability modifier (specially In MacOS) which is only available on masOS 13+ and iOS 17+, but still need to run on macOS 12 or iOS 15… So I need something like #if os(macOS) if #available(macOS 13 *) { use windowResizability #else do not use windowResizability #endif #else // iOS if #available(iOS 17 *) { use windowResizability #else do not use windowResizability #endif Here is the code where to apply (in @main) struct TheApp: App { var body: some Scene { WindowGroup { ContentView() // 1.11.2023 .frame( minWidth: 1200, maxWidth: .infinity, minHeight: 600, maxHeight: .infinity) } .windowResizability(.contentSize) // BTW: is that really necessary ? } } How can I achieve this ? Do I need to write a WindowGroup extension for the modifier ? If so, how ? BTW: is windowResizability really necessary ? App seems to work the same without it.
1
1
707
Oct ’24
iOS 18: "Invalid number of items in section 0"
Hi, I recently started experiencing the following bug in the code listed below. The app is a dieting/calorie logging app with a function that presents a List() of calories in different days, separated into sections for each Meal as derived from an array of Meals. Part of this functionality is that the user can swipe an entry in the List to delete one. If the user has one entry and they delete it, behaviour is as expected. If they have more than one entry and they delete one, behaviour is as expected. If they have more than one entry and they delete two items, one after another, the app crashes with the message "Invalid number of items in section 0". If they have more than one entry and they delete one, then go back to the main screen of the app, then delete another one, behaviour is as expected. Searches online suggest that this is because the array underpinning the list has not updated. However the app crashes before it has even reached the delete() function called by onDelete, so there is no opportunity to update the model before something refreshes and the app crashes. Does anyone have any idea how to resolve this? This code worked fine up until iOS 18. List { if list.budgieData.count != 0 { ForEach(list.mealList.indices, id: \.self) { idx in Section(header: Text(list.mealList[idx].name)) { ForEach(list.budgieData.indices, id: \.self) { entryIdx in if list.budgieData[entryIdx].meal == list.mealList[idx].mealUUID { CalorieEntryView(calories: list.budgieData[entryIdx].calories, narrative: list.budgieData[entryIdx].narrative ?? "Quick calories", realEntry: list.budgieData[entryIdx].realEntry, date: list.budgieData[entryIdx].date) } }.onDelete(perform: delete) } } } else { Text("You have no calories logged in Budgie Diet on this day.") } if list.hkCalories != 0 { Section(header: Text("Calories from other apps"), footer: Text("These are calories logged in Health by other apps. You'll need to go to the app that logged them to change or delete them.")) { CalorieEntryView(calories: list.hkCalories, narrative: "Calories from other apps", realEntry: false, date: list.curDate) .deleteDisabled(true) } } }.listStyle(.grouped)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
0
0
200
Oct ’24
Apple Maps Not responding to scrolling, zooming, or tap gestures on custom pins
Scrolling and zooming I have two apps that utilize the Apple Maps and since I updated my xcode to use IOS18, some of the functionalities have either been missing or glitching, and when I roll back to IOS17.5, everything seems to work fine. When I use MKMapView and use mapView.isZoomEnabled = true mapView.isScrollEnabled = true Scrolling and zooming is still not working on IOS18 but IOS17.5 works fine. Clicking on custom annotations When I press on a custom annotation I add to the MapView, the gesture is sometimes recognized and most of the times not recognized. If I have 20 annotations, there is a possibility only 2 of them respond to tap gestures. Below is how I define the annotation. Annotation("Pin", coordinate: CLLocationCoordinate2D(latitude: latitude, longitude: longitude), anchor: .bottom) { Button(action: {print ("Pressed annotation"){ CustomPin() } }
0
0
349
Oct ’24
Xcode 16.0 + SwiftUI: Failed to launch app "MyApp.app" in reasonable time
I am working on transitioning an existing UIKit based app to SwiftUI. After adding a first SwiftUI file to the project preview fails with: Failed to launch app "MyApp.app" in reasonable time The View code is the default templates, thus definitly not too complex: import SwiftUI struct OverviewPageView: View { var body: some View { Text("Hello, World!") } } #Preview { OverviewPageView() } Things I have tried: Cleaning and rebuilding. Changing the target device. Using xcrun simctl shutdown all followed by scrub simctl erase all Clearing the contents of my ~/Library/Developer/Xcode/UserData/Previews folder. Clearing the contents of my ~/Library/Developer/Xcode/DerivedDatas folder. Using xcrun simctl --set previews delete all Restarting macOS and Xcode The problem seems tpbe related to my project. When creating a fresh new project using "Storyboard" as interface and adding a SwiftUI file, the preview works fine. However, this does not help when working on my existing project... I generated a preview diagnostics report. I am using Xcode 16.0 on macOS 15.0
3
2
818
Oct ’24
LinkPresentation startFetchingMetadata errors
I’m trying to use the Link Presentation app in my SwiftUI app. When I try to fetch metadata, I get quite a few errors in the console. Here’s a stripped down version of the code that causes errors: public struct URLMetadataLoader { public static func metadata(for url: URL) async -> LPLinkMetadata? { let metadataProvider = LPMetadataProvider() do { let metadata = try await metadataProvider.startFetchingMetadata(for: url) return metadata } catch { print("Failed to get metadata for URL: \(error.localizedDescription)") return nil } } } The errors I get on every call to fetch metadata are below. Thanks. Failed to resolve host network app id to config: bundleID: com.apple.WebKit.Networking instance ID: Optional([_EXExtensionInstanceIdentifier: 0501F943-B5B6-4F60-95B0-CDECFC2AE908]) Type: Error | Timestamp: 2024-10-07 12:17:36.877477-05:00 | Process: URLMetaDataMinimal | Library: ExtensionFoundation | Subsystem: com.apple.extensionkit | Category: default | TID: 0x1f1c18 Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "((target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.rendering AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.networking AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.webcontent))" UserInfo={NSLocalizedFailureReason=((target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.rendering AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.networking AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.webcontent))}> 0x12602cd80 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'XPCConnectionTerminationWatchdog' for process with PID=80284, error: (null) Failed to terminate process: Error Domain=com.apple.extensionKit.errorDomain Code=18 "(null)" UserInfo={NSUnderlyingError=0x600000c6fbd0 {Error Domain=RBSRequestErrorDomain Code=3 "No such process found" UserInfo={NSLocalizedFailureReason=No such process found}}} Failed to terminate process: Error Domain=com.apple.extensionKit.errorDomain Code=18 "(null)" UserInfo={NSUnderlyingError=0x600000c8cc60 {Error Domain=RBSRequestErrorDomain Code=3 "No such process found" UserInfo={NSLocalizedFailureReason=No such process found}}}
Topic: UI Frameworks SubTopic: General
2
1
908
Oct ’24
SwiftUI List insertion changes aren't animated on macOS 15
I've been struggling with this issue since the release of macOS 15 Sequoia. I'm wondering if anyone else has encountered it or if anyone has a workaround to fix it. Inserting a new element into the array that acts as data source for a SwiftUI List with a ForEach is never animated even if the insertion is wrapped in a withAnimation() call. It seems that some other changes can be automated though: e.g. calls to shuffle() on the array successfully animate the changes. This used to work fine on macOS 14, but stopped working on macOS 15. I created a very simple project to reproduce the issue: import SwiftUI @main struct TestApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct IdentifiableItem: Identifiable { let id = UUID() var name: String { "Item \(id)" } } struct ContentView: View { @State var items: [IdentifiableItem] = [ IdentifiableItem(), IdentifiableItem(), IdentifiableItem(), IdentifiableItem(), IdentifiableItem(), IdentifiableItem(), IdentifiableItem(), IdentifiableItem(), IdentifiableItem(), IdentifiableItem(), ] var body: some View { List { ForEach(items) { item in Text(item.name) } } Button("Add Item") { withAnimation { items.insert(IdentifiableItem(), at: 0) } } Button("Shuffle Items") { withAnimation { items.shuffle() } } } } How to reproduce Copy the code below in an Xcode project. Run it on macOS 15. Hit the "Add Item" button Expected: A new item is inserted with animation. Result: A new item is inserted without animation. How to prove this is a regression Follow the same steps above but run on macOS 14. A new item is inserted with animation.
2
1
445
Oct ’24
iOS 18 tabbar flickers and then disappears
Use a UITabBarController to load two ViewControllers, A and B, both wrapped in UINavigationController. In A’s viewDidLoad method, push to C, with C’s hidesBottomBarWhenPushed set to true. When popping back to A, the tab bar flickers and then disappears. In versions lower than iOS 18, after popping back, the tabBar does not flicker and disappear. A ViewController override func viewDidLoad() { super.viewDidLoad() let vc = CViewController() vc.hidesBottomBarWhenPushed = true navigationController?.pushViewController(vc, animated: true) // Do any additional setup after loading the view. }
Topic: UI Frameworks SubTopic: UIKit Tags:
2
0
937
Oct ’24
Vertical ScrollView Height and Paging Offset Issues in SwiftUI
Hi everyone, I'm currently working on an iOS app using SwiftUI, and I'm facing an issue with a vertical ScrollView. My goal is to have the ScrollView take up all the safe area space plus the top inset (with the bottom inset being an ultra-thin material) and enable paging behavior. However, I'm encountering two problems: The initial height of the ScrollView is too high (dragging the view (even without changing the page) adjusts the size). The paging offset of the ScrollView is incorrect (page views are not aligned). I’ve tried many things and combinations in desperation, including padding, safeAreaPadding, contentMargins, frame, fixedSize, containerRelativeFrame with callback, custom layout, and others, but nothing seems to work. If by any chance someone can help me find a solution, I’d greatly appreciate it. I suspect there are issues with the height defined by the ScrollView when some safe areas are ignored, leading to strange behavior when trying to set the height. It's challenging to explain everything in a simple post, so if someone from the SwiftUI team could look into this potential bug, that would be incredibly helpful. Thank you! import SwiftUI struct ScrollViewIssue: View { @State private var items: [(String, Color)] = [ ("One", .blue), ("Two", .green), ("Three", .red), ("Four", .purple) ] var body: some View { ZStack(alignment: .top) { ScrollView(.vertical) { VStack(spacing: 0) { ForEach(items, id: \.0) { item in ItemView(text: item.0, color: item.1) .containerRelativeFrame([.horizontal, .vertical]) } } } .printViewSize(id: "ScrollView") .scrollTargetBehavior(.paging) .ignoresSafeArea(edges: .top) VStack { Text("Title") .foregroundStyle(Color.white) .padding() .frame(maxWidth: .infinity) .background(Color.black.opacity(0.2)) Spacer() } } .printViewSize(id: "ZStack") .safeAreaInset(edge: .bottom) { Rectangle() .frame(width: .infinity, height: 0) .overlay(.ultraThinMaterial) } } } struct ItemView: View { let text: String let color: Color var body: some View { ZStack { RoundedRectangle(cornerRadius: 20) .fill(color.opacity(0.2)) .overlay( color, in: RoundedRectangle(cornerRadius: 20) .inset(by: 10 / 2) .stroke(lineWidth: 10) ) Text(text) } .printViewSize(id: "item") } } struct ViewSizeKey: PreferenceKey { static var defaultValue = CGSize() static func reduce(value: inout CGSize, nextValue: () -> CGSize) { value = nextValue() } } extension View { func printViewSize(id: String) -> some View { background( GeometryReader { proxy in Color.clear .preference(key: ViewSizeKey.self, value: proxy.size) } .onPreferenceChange(ViewSizeKey.self) { value in print("\(id) size:\(value)") } ) } } #Preview { ScrollViewIssue() }
3
1
3.2k
Oct ’24
Issue: Device Dock pops up on switching the app to or from Single App mode
I have an issue while unlocking the app from Single App mode. Device Dock is popping up on top of my app and this is disturbing the experience of my app. I have already done MDM configuration and the indented functionality is working fine with the below code, the app is successfully switching to single app mode and back. The sample code below reproduces the issue. Tap on Lock, the completion blocks returns true and the app is successfully switched to single app mode. Tap on Unlock, the completion block returns true and the app is successfully switched from the single app mode. Now the device dock is popped up on top of the app. struct LockApp: App { var body: some Scene { WindowGroup { VStack { Button("Lock", systemImage: "lock") { UIAccessibility.requestGuidedAccessSession(enabled: true) { success in print("App has been locked", success) } } .buttonStyle(.borderedProminent) Button("UnLock", systemImage: "lock.open") { UIAccessibility.requestGuidedAccessSession(enabled: false) { success in print("App has been unlocked", success) } } .buttonStyle(.borderedProminent) } } } } Xcode Version: 16.0 Device: iPad Pro 12.9 inch 6th gen. OS: 18.1 Is this intended behaviour? Has anyone come across this issue?
1
1
315
Oct ’24
Anyone getting BUG IN CLIENT OF UIKIT: The caller of UIApplication.openURL(:) needs to migrate... with Python webbrowser in a IOS Kivy app ?
Hi everyone, If you're encountering the following error in Xcode while executing a simple webbrowser.open() command in your Python file, you're in the right place: "BUG IN CLIENT OF UIKIT: The caller of UIApplication.openURL(:) needs to migrate to the non-deprecated UIApplication.open(:options:completionHandler:). Force returning false (NO)." This issue arises because, starting from iOS 18, the UIApplication.openURL(:) method has been deprecated. If you created your project, dependencies, and the kivy-ios folder before iOS 18, every time you try to open a URL, the deprecated method will be called. To resolve this issue without rebuilding the entire project and waiting for the kivy-ios toolchain to be updated, simply follow these steps: At the very top of your main.py file remplace import webbrowser by : from pyobjus import autoclass from pyobjus.dylib_manager import load_framework load_framework('/System/Library/Frameworks/UIKit.framework') NSURL = autoclass('NSURL') UIApplication = autoclass('UIApplication') def open_url(url): nsurl = NSURL.URLWithString_(url) app = UIApplication.sharedApplication() options = {} app.openURL_options_completionHandler_(nsurl, options, None) Then replace all your webbrowser.open(url) commands by open_url(url) You no longer need webbrowser. Hope it helped.
Topic: UI Frameworks SubTopic: UIKit
0
0
2.2k
Oct ’24
Prevent Virtual Keyboard for iOS App run in macOS
I have a (pretty basic) app I have developed which essentially just opens a pre-defined website (via URL) in WebView. It operates nicely in iOS and almost exactly as expected when run on my M1 in macOS with the exception that in macOS it keeps popping up a grey bar which ... after some investigating ... I have determined appears to be the virtual keyboard. Pressing escape clears it however I am trying to find some way of preventing it from coming up in the first place when the app is run in macOS. Is there a (hopefully simple) solution either through code or some app setting for this?
0
0
338
Oct ’24
Hand Gesture Controls in an Apple Watch App
Hello everyone! I want to add hand gesture controls to my Apple Watch app. Specifically, I’m looking to implement the following gestures: 1. Tapping index finger and thumb together once 2. Tapping index finger and thumb together twice 3. Fist clench 4. Double fist clench Each gesture should trigger a different action within the app. However, I can’t find any information on how to implement this. I only came across an example using .handGestureShortcut(.primaryAction) (Enabling the double-tap gesture on Apple Watch https://developer.apple.com/documentation/watchOS-Apps/enabling-double-tap), but I need to handle four distinct gestures. Is this possible in watchOS 11? Any guidance or examples would be greatly appreciated! Thank you!
1
0
590
Oct ’24
Keyboard Done Button Failing to Appear About 60% of Time
I am working on an app that saves transaction entries. The user is requested to enter date / time, select local currency, payment type, category, description, and expense amount. When entering the description and entry amount they may tap the Done button above the keyboard to dismiss the keyboard. The problem is that quite commonly the Done button doesn't appear and with the decimal keyboard there is no way to dismiss the keyboard. I would say that the Done button appears only about 30-40% of the time. In the EntryView structure, I define the @FocusStatus and pass it down to GetDescription(myFocus: myFocus) and GetMoney(myFocus: myFocus). Further down in EntryView under the toolbar I setting up the Done Button operation and resetting myFocus to nil. In GetMoney I am using the binding var myFocus: FocusState<EntryView.Field?>.Binding. Finally below the GetMoney TextField("Amount" ... there is the .focused(myFocus, equals: .ckAmt GetDescription is not much of a problem because the default keyboard has a built in done button (.submitLabel(.done)). I have Focus / Done operation in four other locations in my app where this works just fine. I need help figuring out why it fails part of the time. struct EntryView: View { enum Field: Hashable { case ckDsc case ckAmt } @FocusState private var myFocus: Field? var body: some View { GeometryReader { g in VStack { Form { GetDate(entryDT: $entryDT) GetCurrency() GetPaymentType(g: g, entryPT: $entryPT) GetCategory(entryCat: $entryCat) GetDescription(g: g, entryDsc: $entryDsc, myFocus: $myFocus) GetMoney(g: g, moneyD: $moneyD, myFocus: $myFocus) } } .navigationBarTitleDisplayMode(.inline) .toolbarBackground(.visible, for: .navigationBar) .toolbarBackground(Color.orange, for: .navigationBar) .toolbar(content: { ToolbarItemGroup(placement: .keyboard) { Spacer() Button("Done") { myFocus = nil } } ToolbarItem(placement: .principal) { VStack (alignment: .leading) { HStack { Text("Expense Entry") .font(.title) .bold() .kerning(1.5) .padding(.leading, 10) .frame(maxWidth: .infinity, alignment: .leading) Spacer() Button { myFocus = nil if moneyD != 0.0 { self.saveButton() // button pressed } if !zeroEntry { dismiss() } } label: { Text("Save") .bold() .padding(.trailing, 10) .tint(.blue) } .disabled(moneyD == 0.0) } } } }) } } // Entry save button has been pressed: save data to swiftdata func saveButton() { } } struct GetMoney: View { var g: GeometryProxy @Binding var moneyD: Double? var myFocus: FocusState<EntryView.Field?>.Binding var body: some View { Section(header: Text("Enter Amount")) { HStack { TextField("Amount", value: $moneyD, format: .number.precision(.fractionLength(0...2))) .focused(myFocus, equals: .ckAmt) .font(.headline) .padding(.vertical, 10) .keyboardType(.decimalPad) } } } } }
2
0
464
Oct ’24
Customizing ToolBar of SplitView
Hi, Os to possible to customize the icon, color, positioning of the SplitView ToolBar that shows at details view, the menu blue icon. add buttons to it ? change its color, icon, size ? position like adding paddings ? Kind Regards
1
0
545
Oct ’24