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

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
131
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
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
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
209
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
118
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
197
Aug ’24
How to make third party peripheral discoverable using iOS 18 AccessorySetupKit
As the new feature is launched I also want to make user experience smoother in my app using the AccessorySetupKit. But my peripheral is not discoverable. But another ios device with same advertisement data is discoverable by AccessorySetupKit. I didn't find much information on the documents related to the third party connection. I'm not sure if the third party peripheral should be MFI supported or anything else is required. Is there anything I'm missing here to fullfill the requirement, please let me know. Below is the code i"m using to discover the peripheral. Once again iOS to iOS discovery is working, facing issue with third party peripheral is not discovering. private var session = ASAccessorySession() var pickerDismissed = true private static let perepheral: ASPickerDisplayItem = { let descriptor = ASDiscoveryDescriptor() descriptor.bluetoothServiceUUID = PublisherClass.serviceUUID return ASPickerDisplayItem( name: "Test_Name", productImage: UIImage(named: "sample")!, descriptor: descriptor ) }() override func viewDidLoad() { super.viewDidLoad() self.session.activate(on: DispatchQueue.main, eventHandler: handleSessionEvent(event:)) } @IBAction func presentPicker() { session.showPicker(for: [Self.perepheral]) { error in if let error { print("Failed to show picker due to: \(error.localizedDescription)") } } } private func handleSessionEvent(event: ASAccessoryEvent) { switch event.eventType { case .accessoryAdded, .accessoryChanged: guard let accessory = event.accessory else { return } print("\(accessory)") case .activated: guard let accessory = session.accessories.first else { return } print("\(accessory)") case .accessoryRemoved: print("Received event type accessoryRemoved)") case .pickerDidPresent: pickerDismissed = false case .pickerDidDismiss: pickerDismissed = true default: print("Received event type \(event.eventType)") } } } I also added these details in plist NSAccessorySetupKitSupports Bluetooth NSAccessorySetupBluetoothServices
0
0
193
Aug ’24
Fatal Exception: NSInternalInconsistencyException UIGraphicsBeginImageContext() failed to allocate CGBitampContext: size={0, 1133}, scale=2.000000, bitmapInfo=0x2002. Use UIGraphicsImageRenderer to avoid this assert.
I have a .Net MAUI App. As soon as i close the app or put in the background the app crashes instantly. It only happens on OS version: iPad OS 17.5.1 Model:iPad mini (6th generation). Below is the exception logged on firebase crashlytics Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UIGraphicsBeginImageContext() failed to allocate CGBitampContext: size={0, 0}, scale=3.000000, bitmapInfo=0x2002. Use UIGraphicsImageRenderer to avoid this assert.' Any suggestions or ideas ?
0
0
206
Aug ’24
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
216
Aug ’24
App Icon all black on ios17, works on iOS18, building app in Xcode16 beta
In my app I added an AppIcon in the Assets.xcassets folder. I added a any/dark/tinted version of the app icon, in 1024x1024 resolution as a HEIC file, specifying a "single size" iOS option. When I build and run the app in xcode16 beta on iOS18 the icon works as expected, but when I run the same app on iOS17 the icon just shows up as a black rectangle. How do I get the app icon to work correctly on both iOS18 and iOS17?
1
0
310
Aug ’24
ControlWigdet Open APP with URL
This code can open app, but the deep link is not send to the app. It doesn't seem to call the UIApplicationDelegate's "application(_:open:options:)" method, so I can't read the link string that was passed in func perform() async throws -> some IntentResult & OpensIntent { guard let url = URL(string: "myapp://myappintent") else { // throw an error of your choice here } return .result(opensIntent: OpenURLIntent(deepLink)) }
1
1
320
Aug ’24
ControlWidget Can't use onOpenURL
`struct OpenMainAppIntent: AppIntent { static let title: LocalizedStringResource = "OpenMainAppIntent" static var openAppWhenRun: Bool = true init() {} @MainActor func perform() async throws -> some IntentResult & OpensIntent { guard let url = URL(string: "myapp://open") else { throw OpenURLError.invalidURL } return .result(opensIntent: OpenURLIntent(url)) } } ` This is an action in my custom control widget, and i want to use this deeplink open my application and get the link's info, but it won't perform onOpenURL `@main struct TestControlWidgetApp: App { var body: some Scene { WindowGroup { ContentView() .onOpenURL { url in print("url: \(url)") } } } }`
2
0
285
Aug ’24