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.

Post

Replies

Boosts

Views

Activity

Unable to import Charts in Xcode 16.1 beta 2
Failed to build module 'Charts'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 6.0 effective-5.10 (swiftlang-6.0.0.7.41 clang-1600.0.24.1)', while this compiler is 'Apple Swift version 6.0 effective-5.10 (swiftlang-6.0.0.9.11 clang-1600.0.26.2)'). Please select a toolchain which matches the SDK. Any fix yet?
1
2
157
1w
iOS 18 hit testing functionality differs from iOS 17
I created a Radar for this FB14766095, but thought I would add it here for extra visibility, or if anyone else had any thoughts on the issue. Basic Information Please provide a descriptive title for your feedback: iOS 18 hit testing functionality differs from iOS 17 What type of feedback are you reporting? Incorrect/Unexpected Behavior Description: Please describe the issue and what steps we can take to reproduce it: We have an issue in iOS 18 Beta 6 where hit testing functionality differs from the expected functionality in iOS 17.5.1 and previous versions of iOS. iOS 17: When a sheet is presented, the hit-testing logic considers subviews of the root view, meaning the rootView itself is rarely the hit view. iOS 18: When a sheet is presented, the hit-testing logic changes, sometimes considering the rootView itself as the hit view. Code: import SwiftUI struct ContentView: View { @State var isPresentingView: Bool = false var body: some View { VStack { Text("View One") Button { isPresentingView.toggle() } label: { Text("Present View Two") } } .padding() .sheet(isPresented: $isPresentingView) { ContentViewTwo() } } } #Preview { ContentView() } struct ContentViewTwo: View { @State var isPresentingView: Bool = false var body: some View { VStack { Text("View Two") } .padding() } } extension UIWindow { public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { /// Get view from superclass. guard let hitView = super.hitTest(point, with: event) else { return nil } print("RPTEST rootViewController = ", rootViewController.hashValue) print("RPTEST rootViewController?.view = ", rootViewController?.view.hashValue) print("RPTEST hitView = ", hitView.hashValue) if let rootView = rootViewController?.view { print("RPTEST rootViewController's view memory address: \(Unmanaged.passUnretained(rootView).toOpaque())") print("RPTEST hitView memory address: \(Unmanaged.passUnretained(hitView).toOpaque())") print("RPTEST Are they equal? \(rootView == hitView)") } /// If the returned view is the `UIHostingController`'s view, ignore. print("MTEST: hitTest rootViewController?.view == hitView", rootViewController?.view == hitView) print("MTEST: -") return hitView } } Looking at the print statements from the provided sample project:
 iOS 17 presenting a sheet from a button tap on the ContentView(): RPTEST rootViewController's view memory address: 0x0000000120009200 RPTEST hitView memory address: 0x000000011fd25000 RPTEST Are they equal? false MTEST: hitTest rootViewController?.view == hitView false RPTEST rootViewController's view memory address: 0x0000000120009200 RPTEST hitView memory address: 0x000000011fd25000 RPTEST Are they equal? false MTEST: hitTest rootViewController?.view == hitView false iOS 17 dismiss from presented view: RPTEST rootViewController's view memory address: 0x0000000120009200 RPTEST hitView memory address: 0x000000011fe04080 RPTEST Are they equal? false MTEST: hitTest rootViewController?.view == hitView false RPTEST rootViewController's view memory address: 0x0000000120009200 RPTEST hitView memory address: 0x000000011fe04080 RPTEST Are they equal? false MTEST: hitTest rootViewController?.view == hitView false iOS 18 presenting a sheet from a button tap on the ContentView(): RPTEST rootViewController's view memory address: 0x000000010333e3c0 RPTEST hitView memory address: 0x0000000103342080 RPTEST Are they equal? false MTEST: hitTest rootViewController?.view == hitView false RPTEST rootViewController's view memory address: 0x000000010333e3c0 RPTEST hitView memory address: 0x000000010333e3c0 RPTEST Are they equal? true MTEST: hitTest rootViewController?.view == hitView true You can see here ☝️ that in iOS 18 the views have the same memory address on the second call and are evaluated to be the same. This differs from iOS 17. iOS 18 dismiss RPTEST rootViewController's view memory address: 0x000000010333e3c0 RPTEST hitView memory address: 0x0000000103e80000 RPTEST Are they equal? false MTEST: hitTest rootViewController?.view == hitView false RPTEST rootViewController's view memory address: 0x000000010333e3c0 RPTEST hitView memory address: 0x0000000103e80000 RPTEST Are they equal? false MTEST: hitTest rootViewController?.view == hitView false The question I want to ask: Is this an intended change, meaning the current functionality in iOS 18 is expected? Or is this a bug and it's something that needs to be fixed? As a user, I would expect that the hit testing functionality would remain the same from iOS 17 to iOS 18. Thank you for your time.
7
7
851
Aug ’24
Square Notification Box
Apparently, the half-a-sec boxy notification issue remains up until now??? Please help fix the bug, Apple Dev. how come an issue from ios 16 still happening now in ios 18? reference: https://www.reddit.com/r/ios/s/Qx116rGBzM
0
0
64
1w
Home Screen Icons
Now that we are finally able to customize our home screen, can you disable the auto relocation feature? Making it extremely difficult to customize home screen when things are still moving around automatically. Thanks.
1
0
89
1w
Public generated asset symbols
Is there currently an option to make generated asset symbols public? If not, would it be possible to set the generated asset symbol so they are public. It's quite common to have an apps design system implemented in a separate framework. Currently the generate assets symbols is useless for this as they can't be access in the framework consumer. It would be great to add it to this new dropdown in Xcode 16 or along side it. (113704993 in the release notes) So the options would be Internal, Public and Off. This should affect the symbols, the extensions and the framework support. (There's a post on the swift forums about this as well here: https://forums.swift.org/t/generate-images-and-colors-inside-a-swift-package/65674)
3
11
902
Jun ’24
How to get new push token for Live Activity using input-push-token option
The documentation doesn't state how to get the new APNs push token that is associated with a Live Activity that is started via an APNs push notification. I have been able to get the new token by listening to all instances of the Live Activities for my attribute type, but it makes me wonder how the "input-push-token" option for iOS 18 is supposed to work. Is there another way to retrieve the newly created Live Activity push token when using "input-push-token"?
1
1
173
2w
Limitations for attributes in SwiftData models?
Hi, is there any description/documentation about what can not be used as SwiftData attributes? I do not mean things which cause issues at compile time, like having a type which is not Codeable. But rather I am looking for info which things to avoid, if you do not want to run into application crashes in modelContext.save(). Like for example having an enum which as an optional associated value as an attribute type (crashes on save is the associated value is nil). Anybody seen any documentation about that? Or tech notes? Thanks in advance for any hints :-). Cheers, Michael
1
1
218
Aug ’24
iPad native camera vs AVFoundation device
We are trying to build a video recording app using AVFoundation and AVCaptureDevice. No custom settings are used like iso, exposure duration. All the settings are kept to auto. But when video is captured using front camera and 1080x1920 dimensions, the video captured from the app and front native camera does not match. In settings i have kept video setting as 30 fps 1080x1920. The video captured from the app includes more area than the native app. Also some values like iso, exposure duration does not match. So is there any way to capture video exactly same as native camera using AVFoundation and AVCaptureDevice. I have attached screenshots from video for reference. Native AVCapture
0
0
132
2w
iOS 18 Beta 2 XCTest: Unable to record and play contacts permission system dialog
Unable to record and play the new contacts permission system dialog. App: https://developer.apple.com/documentation/contacts/accessing-a-person-s-contact-data-using-contacts-and-contactsui func handleContactsAccessAlert() { let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") let allowButton = springboard.buttons["Allow Full Access"] allowButton.tap() let access6ContactsButton = springboard.alerts["Allow full access to 6 contacts?"].scrollViews.otherElements.buttons["Allow"] access6ContactsButton.tap() } func handleContactsPermissionAlert() { let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") let allowButton = springboard.buttons["Continue"] if allowButton.exists { allowButton.tap() sleep(5) handleContactsAccessAlert() } } func testContactPermissions() { let app = XCUIApplication() app.launch() app.buttons["Request Access"].tap() sleep(5) handleContactsPermissionAlert() sleep(5) app.collectionViews/*@START_MENU_TOKEN@*/.staticTexts["Kate Bell"]/*[[".cells.staticTexts[\"Kate Bell\"]",".staticTexts[\"Kate Bell\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap() }
3
1
502
Jul ’24
Open specific screen in App Delegate after iOS 18 Control Center widget is tapped (failed to open URL)
I have created an iOS 18 Control Center Widget that launches my app. However I am not able to detect it in AppDelegate.swift. I have created custom scheme funRun://beginRun in Target => Info => URL Types URL Types setup in Xcode This method in AppDelegate.swift does not fire at all and I get this error in console: Failed to open URL runFun://beginRun: Error Domain=NSOSStatusErrorDomain Code=-10814 "(null)" UserInfo={_LSLine=279, _LSFunction=-[_LSDOpenClient openURL:fileHandle:options:completionHandler:]}`` ` func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { // this does not fire print("Scheme \(url.scheme)") print("Host \(url.host)") return true }` I tried this answer to no avail: iOS 18 Control Widget that opens a URL Even adding EnvironmentValues().openURL(url) as suggested here did not help. @MainActor func perform() async throws -> some IntentResult & OpensIntent { let url = URL(string: "funRun://beginRun")! EnvironmentValues().openURL(url) return .result(opensIntent: OpenURLIntent(url)) } Here is my extension code: My goal is to detect the url string from the request, so I can decide which screen to launch from AppDelegate's open url method. When I test this with iOS 18 RC it does not work either in simulator or on real device import AppIntents import SwiftUI import WidgetKit @available(iOS 18.0, watchOS 11.0, macOS 15.0, visionOS 2.0, *) struct StartRunControl: ControlWidget { var body: some ControlWidgetConfiguration { StaticControlConfiguration( kind: "name.funRun.StartRun", provider: Provider() ) { value in ControlWidgetButton("Hello", action: MyIntent()) { hi in Label("Start", systemImage: "sun.min.fill") } } .displayName("Start run") .description("Opens a run screen.") } } @available(iOS 18.0, watchOS 11.0, macOS 15.0, visionOS 2.0, *) extension StartRunControl { struct Provider: ControlValueProvider { var previewValue: Bool { false } func currentValue() async throws -> Bool { let isRunning = true // Check if the timer is running return isRunning } } } @available(iOS 18.0, watchOS 11.0, macOS 15.0, visionOS 2.0, *) struct MyIntent: AppIntent { static let title: LocalizedStringResource = "My Intent" static var openAppWhenRun: Bool = true init() {} @MainActor func perform() async throws -> some IntentResult & OpensIntent { let url = URL(string: "funRun://beginRun")! EnvironmentValues().openURL(url) return .result(opensIntent: OpenURLIntent(url)) } } I even checked info.plist and it seems okay. <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLName</key> <string>beginRun</string> <key>CFBundleURLSchemes</key> <array> <string>funRun://beginRun</string> </array> </dict> </array> Does anyone know where the problem might be? Thanks!
1
0
258
2w
Is there a way to detect front camera location on the newest iPad Pro's and Air's?
With the newest iPad Pro and iPad Air's, the front facing camera sits on the long horizontal edge, which is different from the previous version which had the camera on the shorter top edge. We have an app that needs to put a UI item near the camera. Is there a way of detecting where the front facing camera is on iOS? I have tried doing simple resolution checks, i.e, if width == ipadProWidth || width == ipadAirWidth { do2024iPadProLayout() } else { doStandardiPadLayout() } But this doesn't feel like the nicest way to do this check, because it's liable to break moving forward, and theres the possibility Apple release more devices with the camera on the horizontal edge. Any help here is appreciated!
1
1
156
2w
PDFKit shows popup asking to download embedded font. Any way to disable this behavior?
I'm building a MacOS app which reads a lot of PDFs in the background. Some of these PDF's have an embedded font which is not installed on the system. In such cases the app shows a popup asking whether to Download or Skip the font. This seems to be a PDFKit behavior because I see the same behavior when I open the file in Preview (see screenshot) This behavior is disruptive to the user experience and I'd like to be able to disable font downloads. However I don't see any option in the PDFKit API to do so. Any ideas?
0
0
132
2w
MFMessageComposeViewController, SwiftUI, with attachment
My app needs to send iMessages with an attached data file. The view comes up modally and the user needs to press the send button. When the button is tapped the error occurs and the attachment and message is not delivered. I have tried three implementations of UIViewControllerRepresentable for MFMessageComposeViewController that have worked for iOS 15 and 16, but not 17. If I make the simplest app to show the problem, it will reliably fail on all iOS versions tested. If I remove the attachment, the message gets sent. In contrast, the equivalent UIViewControllerRepresentable for email works perfectly every time. After struggling for weeks to get it to work, I am beginning to believe this is a timing error in iOS. I have even tried unsuccessfully to include dispatch queue delays. Has anybody else written a swiftUI based app that can reliably attach a file to an iMessage send? UIViewControllerRepresentable: import SwiftUI import MessageUI import UniformTypeIdentifiers struct AttachmentData: Codable { var data:Data var mimeType:UTType var fileName:String } struct MessageView: UIViewControllerRepresentable { @Environment(\.presentationMode) var presentation @Binding var recipients:[String] @Binding var body: String @Binding var attachments:[AttachmentData] @Binding var result: Result<MessageComposeResult, Error>? func makeUIViewController(context: Context) -> MFMessageComposeViewController { let vc = MFMessageComposeViewController() print("canSendAttachments = \(MFMessageComposeViewController.canSendAttachments())") vc.recipients = recipients vc.body = body vc.messageComposeDelegate = context.coordinator for attachment in attachments { vc.addAttachmentData(attachment.data, typeIdentifier: attachment.mimeType.identifier, filename: attachment.fileName) } return vc } func updateUIViewController(_ uiViewController: MFMessageComposeViewController, context: Context) { } func makeCoordinator() -> Coordinator { return Coordinator(presentation: presentation, result: $result) } class Coordinator: NSObject, MFMessageComposeViewControllerDelegate { @Binding var presentation: PresentationMode @Binding var result: Result<MessageComposeResult, Error>? init(presentation: Binding<PresentationMode>, result: Binding<Result<MessageComposeResult, Error>?>) { _presentation = presentation _result = result } func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) { defer { $presentation.wrappedValue.dismiss() } switch result { case .cancelled: print("Message cancelled") self.result = .success(result) case .sent: print("Message sent") self.result = .success(result) case .failed: print("Failed to send") self.result = .success(result) @unknown default: fatalError() } } } } SwiftUI interface: import SwiftUI import MessageUI struct ContentView: View { @State private var isShowingMessages = false @State private var recipients = ["4085551212"] @State private var message = "Hello from California" @State private var attachment = [AttachmentData(data: Data("it is not zip format, however iMessage won't allow the recipient to open it if extension is not a well-known extension, like .zip".utf8), mimeType: .zip, fileName: "test1.zip")] @State var result: Result<MessageComposeResult, Error>? = nil var body: some View { VStack { Button { isShowingMessages.toggle() } label: { Text("Show Messages") } .sheet(isPresented: $isShowingMessages) { MessageView(recipients: $recipients, body: $message, attachments: $attachment, result: $result) } .onChange(of: isShowingMessages) { newValue in if !isShowingMessages { switch result { case .success(let type): switch type { case .cancelled: print("canceled") break case .sent: print("sent") default: break } default: break } } } } } } #Preview { ContentView() }
1
0
210
3w
Crashes in PHPickerViewController PFAssertionPolicyAbort
Hello! I'm getting crash reports in PHPickerViewController for iOS 17 users only. Can someone point me into the right direction what could be the root cause in my case since it's related to PHPickerViewController? Thread 0 name: Thread 0 Crashed: 0 libsystem_kernel.dylib 0x00000001e7e9342c __pthread_kill + 8 (:-1) 1 libsystem_pthread.dylib 0x00000001fbc32c0c pthread_kill + 268 (pthread.c:1721) 2 libsystem_c.dylib 0x00000001a6d36ba0 abort + 180 (abort.c:118) 3 PhotoFoundation 0x00000001d2420280 -[PFAssertionPolicyAbort notifyAssertion:] + 68 (PFAssert.m:432) 4 PhotoFoundation 0x00000001d2420068 -[PFAssertionPolicyComposite notifyAssertion:] + 160 (PFAssert.m:259) 5 PhotoFoundation 0x00000001d242061c -[PFAssertionPolicyUnique notifyAssertion:] + 176 (PFAssert.m:292) 6 PhotoFoundation 0x00000001d241f7f4 -[PFAssertionHandler handleFailureInFunction:file:lineNumber:description:arguments:] + 140 (PFAssert.m:169) 7 PhotoFoundation 0x00000001d2420c74 _PFAssertFailHandler + 148 (PFAssert.m:127) 8 PhotosUI 0x0000000216b59e30 -[PHPickerViewController _handleRemoteViewControllerConnection:extension:extensionRequestIdentifier:error:completionHandler:] + 1356 (PHPicker.m:1502) 9 PhotosUI 0x0000000216b5a954 __66-[PHPickerViewController _setupExtension:error:completionHandler:]_block_invoke_3 + 52 (PHPicker.m:1454) Crash report: 2024-09-05_18-27-56.7526_+0500-a953eaee085338a690ac1604a78de86e3e49d182.crash
1
0
180
3w
Can you limit the number times you share an item with recipients using Share Sheet?
I am looking to use the iOS share sheet in my app where the user can send an invite link to friends, however I want to limit the number of times they can do this. Is it possible to limit the number of recipients who you can share an item using the share sheet, or if there any sort of post-feedback sent from the share sheet back to the app once the share sheet is closed?
0
0
119
3w
Contact Prodvider Extension key 'com.apple.contact.provider.extension' not accepting in Testflight submission
ERROR ITMS-90349: "Invalid Info.plist value. The value of the EXExtensionPointldentifier key, com.apple.contact.provider.extension, in the Info.plist of "MainApp.app/Extensions/ContactProviderExtension.appex" is invalid. We were working on new iOS18 Contacts Provider extension and when try to test the feature in testflight we were unable to submit the build and getting the above error. The extensionPointldentifier 'com.apple.contact.provider.extension' was auto generated by xcode and apple doc mentioned the same value to use for Contacts Provider extension support. But it is not accepting in testflight. https://developer.apple.com/documentation/contactprovider/contactproviderextension Any help will be appreciated.
0
1
356
Aug ’24
App icon color not changing dynamically according to background color from Ventura onwards
In my Swift app for MacOS, I used to set the app icon in status bar with following logic. If dark mode is enabled, white colour template icon If light mode is enabled, black colour template icon Until BigSur with this configuration, if the background wallpaper color was changed being in the same display mode, the status bar icon color used to change dynamically. From Ventura onwards, it does not depend on the background colour anymore with same configuration in the code. Can someone please help here?
0
0
198
Aug ’24