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

How does UIScene know whether it has the main key window and when it changes on iPad's multi-scene?
Hi. I know to know which window gets hardware keyboard events (such as shortcut key) currently on iPad. Until iPadOS 15.0, UIApplication.shared.keyWindow, which was deprecated on iPadOS 13.0 and didBecomeKeyNotification/didResignKeyNotification. But after iPadOS 15.0, a keyWindow is managed by UIScene, not by UIApplication. Each scene of my app always has just one window. For my purpose, checking deprecated UIApplication.shared.keyWindow is still effective but didBecomeKeyNotification and didResignKeyNotification don't work because they are fired when a change happens only inside the scene. So my questions are, What is the new alternative of UIApplication.shared.keyWindow? I know a wrong hack like UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }.first?.windows.filter { $0.isKeyWindow }.first does not work since the order of connectedScenes is not related with getting hardware keyboard events. What are the new alternatives of didBecomeKeyNotification/didResignKeyNotification which work on inter-scene? The second question is more crucial. Because about the first question, I can still use deprecated UIApplication.shared.keyWindow. Thanks.
0
0
166
3w
App Clip show "App Clip Unavailable" only when the main app is not installed
After uploading the app to App Store Connect, Apple automatically generated a Default App Clip Link. However, the App Clip card only opens successfully if the main app is already installed on the device. If the main app is not installed, the App Clip card displays an image and the message "App Clip Unavailable" What could cause this behavior, and how do I ensure the App Clip works without requiring the main app to be installed?
1
0
198
3w
The PKCanvasView Created by PDFPageOverlayViewProvider cannot work normally
By setting the PKCanvasView background color to blue, I can tell that the PKCanvasView for each PDFPage is created normally, but it does not respond to touch. Specifically, whether it is finger or applepencil, all the responses of the page occur from PDFView(such as zoom and scroll), and PKCanvasView can not draw, please how to solve? class PDFAnnotatableViewController: UIViewController, PDFViewDelegate { private let pdfView = PDFView() private var pdfDocument: PDFDocument? let file: FileItem private var userSettings: UserSettings @Binding var selectedPage: Int @Binding var currentMode: Mode @Binding var latestPdfChatResponse: LatestPDFChatResponse @State private var pdfPageCoordinator = PDFPageCoordinator() @ObservedObject var userMessage: ChatMessage init(file: FileItem, userSettings: UserSettings, drawDataList: Binding<[DrawDataItem]>, selectedPage: Binding<Int>, currentMode: Binding<Mode>, latestPdfChatResponse: Binding<LatestPDFChatResponse>, userMessage: ChatMessage) { self.file = file self.userSettings = userSettings self._selectedPage = selectedPage self._currentMode = currentMode self._latestPdfChatResponse = latestPdfChatResponse self.userMessage = userMessage super.init(nibName: nil, bundle: nil) DispatchQueue.global(qos: .userInitiated).async { if let document = PDFDocument(url: file.pdfLocalUrl) { DispatchQueue.main.async { self.pdfDocument = document self.pdfView.document = document self.goToPage(selectedPage: selectedPage.wrappedValue - 1) } } } } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func viewDidLoad() { super.viewDidLoad() setupPDFView() } private func setupPDFView() { pdfView.delegate = self pdfView.autoScales = true pdfView.displayMode = .singlePage pdfView.displayDirection = .vertical pdfView.backgroundColor = .white pdfView.usePageViewController(true) pdfView.displaysPageBreaks = false pdfView.displaysAsBook = false pdfView.minScaleFactor = 0.8 pdfView.maxScaleFactor = 3.5 pdfView.pageOverlayViewProvider = pdfPageCoordinator if let document = pdfDocument { pdfView.document = document goToPage(selectedPage: selectedPage) } pdfView.frame = view.bounds pdfView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(pdfView) NotificationCenter.default.addObserver( self, selector: #selector(handlePageChange), name: .PDFViewPageChanged, object: pdfView ) } // Dealing with page turning @objc private func handlePageChange(notification: Notification) { guard let currentPage = pdfView.currentPage, let document = pdfView.document else { return } let currentPageIndex = document.index(for: currentPage) if currentPageIndex != selectedPage - 1 { DispatchQueue.main.async { self.selectedPage = currentPageIndex + 1 } } } func goToPage(selectedPage: Int) { guard let document = pdfView.document else { return } if let page = document.page(at: selectedPage) { pdfView.go(to: page) } } // Switch function func togglecurrentMode(currentMode: Mode){ DispatchQueue.main.async { if self.currentMode == .none{ self.pdfView.usePageViewController(true) self.pdfView.isUserInteractionEnabled = true } else if self.currentMode == .annotation { if let page = self.pdfView.currentPage { if let canvasView = self.pdfPageCoordinator.getCanvasView(forPage: page) { canvasView.isUserInteractionEnabled = true canvasView.tool = PKInkingTool(.pen, color: .red, width: 20) canvasView.drawingPolicy = .anyInput canvasView.setNeedsDisplay() } } } } } } class MyPDFPage: PDFPage { var drawing: PKDrawing? func setDrawing(_ drawing: PKDrawing) { self.drawing = drawing } func getDrawing() -> PKDrawing? { return self.drawing } } class PDFPageCoordinator: NSObject, PDFPageOverlayViewProvider { var pageToViewMapping = [PDFPage: PKCanvasView]() func pdfView(_ view: PDFView, overlayViewFor page: PDFPage) -> UIView? { var resultView: PKCanvasView? = nil if let overlayView = pageToViewMapping[page] { resultView = overlayView } else { let canvasView = PKCanvasView(frame: view.bounds) canvasView.drawingPolicy = .anyInput canvasView.tool = PKInkingTool(.pen, color: .systemYellow, width: 20) canvasView.backgroundColor = .blue pageToViewMapping[page] = canvasView resultView = canvasView } if let page = page as? MyPDFPage, let drawing = page.drawing { resultView?.drawing = drawing } return resultView } func pdfView(_ pdfView: PDFView, willEndDisplayingOverlayView overlayView: UIView, for page: PDFPage) { guard let overlayView = overlayView as? PKCanvasView, let page = page as? MyPDFPage else { return } page.drawing = overlayView.drawing pageToViewMapping.removeValue(forKey: page) } func savePDFDocument(_ pdfDocument: PDFDocument) -> Data { for i in 0..<pdfDocument.pageCount { if let page = pdfDocument.page(at: i) as? MyPDFPage, let drawing = page.drawing { let newAnnotation = PDFAnnotation(bounds: drawing.bounds, forType: .stamp, withProperties: nil) let codedData = try! NSKeyedArchiver.archivedData(withRootObject: drawing, requiringSecureCoding: true) newAnnotation.setValue(codedData, forAnnotationKey: PDFAnnotationKey(rawValue: "drawingData")) page.addAnnotation(newAnnotation) } } let options = [PDFDocumentWriteOption.burnInAnnotationsOption: true] if let resultData = pdfDocument.dataRepresentation(options: options) { return resultData } return Data() } func getCanvasView(forPage page: PDFPage) -> PKCanvasView? { return pageToViewMapping[page] } } Is there an error in my code? Please tell me how to make PKCanvasView painting normally?
0
0
181
3w
AppClip card keeps showing up
After the user clicks the Open button in the AppClip card, the AppClip launches, but the card keeps appearing whenever the user clicks Open. It doesn’t disappear until the user clicks the Close button on the card. This issue started appearing two months ago and only occurs on iOS 17.6 and 17.7. [demo video](https://drive.google.com/file/d/1vJ-7E5JSdO_xoVkDYxBJDkj8sm-dvxv1/view?usp=share_link
0
0
126
3w
iPhone mirroring and controlling
One of my clients is interested in developing a system similar to BrowserStack for internal team usage. Could you please guide me on how to approach the development of this system? Specifically, the project requires: Full iPhone screen recording. Capturing and executing click events on the iPhone. Do I need to obtain permission from Apple for these functionalities?
0
0
211
4w
Live caller id lookup
We are trying to implement live caller id lookup, there is lack of documentation and we would like to understand few blockers that we have: Based on this documentation page: https://developer.apple.com/documentation/identitylookup/setting-up-the-http-endpoints-for-live-caller-id-lookup: What exactly should accept/return these endpoints?. There is no detailed description of the response/request schema for any endpoint. What are the usage scenarios of the "/key" method? If it is possible to get a more detailed explanation regarding Evaluation Key usage as it is not clear from the available documentation. Based on this step by step implementation description: https://github.com/apple/live-caller-id-lookup-example/blob/main/Sources/PIRService/PIRService.docc/Authentication.md: The 6th step: "Authentication server returns the list of public keys (potentially through a proxy)". What is the endpoint path and response format expected by the iOS system? This step refers to calling the '/config' endpoint ? The 8th step: "Authentication server verifies the User Token and returns the public key that is associated with the User Tier. ..." What is the the endpoint path and request/response format expected by the iOS system? The 9th step: "The system constructs a Privacy Pass token request using the specific public key. The token request is sent along with the User Token to the authentication server". What is the request/response format expected by the iOS system? The 11th step: "When a PIR request is made, the system attached an unused Privacy Pass token to the request. The PIR node can use the public key to verify that the token is valid and that assures that the request is authorized". What is the request/response format expected by the iOS system? On executing refreshPIRParameters fom app I get this error: LiveCallerIDLookupManager.shared.refreshPIRParameters(forExtensionWithIdentifier: LiveCallerIdExtensionName) Unable to query status due to errors: server error (Access DeniedAccess DeniedYou don't have permission to access "http://www.example.com/config" on this server.Reference #18.cdde00d4.1738074526.3a38870https://errors.edgesuite.net/18.cdde00d4.1738074526.3a38870) Why it tries to reach example.com/config but not our serviceURL or tokenIssuerURL? Any help would be appreciated.
0
1
232
4w
-[CPListItem handler] timeout?
Hi all! Based on documentation: https://developer.apple.com/documentation/carplay/cplistitem/handler If you need to perform asynchronous tasks, dispatch them to a background queue and call the completion closure or completionBlock when they complete. In a normal case, it works perfectly. But, if it takes "too much", for example, 10 seconds (streaming with retries, app business logic), when I call the "completionBlock" inside "handler" doesn't do anything. Exists a timeout in "completionBlock"? Thanks!
2
0
226
4w
MVVM design and data dependency
According to the MVVM design pattern, one of my views depends on many properties in my model. Can I use logic like @published var model = MyModel()? Will there be a large performance loss? Will the UI be refreshed when other unrelated properties in the model are modified? What is the best practice in this case?
0
0
162
Jan ’25
Monitoring of the paste(GUI based) operation
I am working on the EndPoint DLP solution project. So I want to monitor the paste operation peformed by the user. So when he uses the keyboard keys then I can monitor them using the event callback. But if user uses the GUI for pasting the data then how can I monitor that ?
0
0
155
Jan ’25
INUIHostedViewControlling ViewController's Life Cycle Events not being Called
I am implementing a new Intents UI Extension and am noticing that the viewWillDisappear, viewDidDisappear, and deinit methods are not being called on my UIViewController that implements INUIHostedViewControlling, when pressing the "Done" button and dismissing the UIViewController. This causes the memory for the UI Extension to slowly increase each time I re-run the UI Extension until it reaches the 120MB limit and crashes. Any ideas as to what's going on here and how to solve this issue? Worth noting that while the memory does continuously increase on iOS versions before iOS 17, only in 17 and later does the 120MB memory limit kick in and crash the extension.
2
0
290
Jan ’25
CATransaction commit() crashed on background thread [EXC_BREAKPOINT: com.apple.root.****-qos.cooperative]
Problem Description We are developing a app for iOS and iPadOS that involves extensive custom drawing of paths, shapes, texts, etc. To improve drawing and rendering speed, we use CARenderer to generate cached images (CGImage) on a background thread. We adopted this approach based on this StackOverflow post: https://stackoverflow.com/a/75497329/9202699. However, we are experiencing frequent crashes in our production environment that we can hardly reproduce in our development environment. Despite months of debugging and seeking support from DTS and the Apple Feedback platform, we have not been able to fully resolve this issue. Our recent crash reports indicate that the crashes occur when calling CATransaction.commit(). We suspect that CATransaction may not be functioning properly outside the main thread. However, based on feedback from the Apple Feedback platform, we were advised to use CATransaction.begin() and CATransaction.commit() on a background thread. If anyone has any insights, we would greatly appreciate it. Code Sample The line CATransaction.commit() is causing the crash: [EXC_BREAKPOINT: com.apple.root.****-qos.cooperative] private let transactionLock = NSLock() // to ensure one transaction at a time private let device = MTLCreateSystemDefaultDevice()! @inline(never) static func drawOnCGImageWithCARenderer( layerRect: CGRect, itemsToDraw: [ItemsToDraw] ) -> CGImage? { // We have encapsulated everything related to CALayer and its // associated creations and manipulations within CATransaction // as suggested by engineers from Apple Feedback Portal. transactionLock.lock() CATransaction.begin() // Create the root layer. let layer = CALayer() layer.bounds = layerRect layer.masksToBounds = true // Add one sublayer for each item to draw itemsToDraw.forEach { item in // We have thousands or hundred thousands of drawing items to add. // Each drawing item may produce a CALayer, CAShapeLayer or CATextLayer. // This is also why we want to utilise CARenderer to leverage GPU rendering. layer.addSublayer( item.createCALayerOrCATextLayerOrCAShapeLayer() ) } // Create MTLTexture and CARenderer. let textureDescriptor = MTLTextureDescriptor.texture2DDescriptor( pixelFormat: .rgba8Unorm, width: Int(layer.frame.size.width), height: Int(layer.frame.size.height), mipmapped: false ) textureDescriptor.usage = [MTLTextureUsage.shaderRead, .shaderWrite, .renderTarget] let texture = device.makeTexture(descriptor: textureDescriptor)! let renderer = CARenderer(mtlTexture: texture) renderer.bounds = layer.frame renderer.layer = layer.self /* ********************************************************* */ // From our crash report, this is where the crash happens. CATransaction.commit() /* ********************************************************* */ transactionLock.unlock() // Rendering layers onto MTLTexture using CARenderer. renderer.beginFrame(atTime: 0, timeStamp: nil) renderer.render() renderer.endFrame() // Draw MTLTexture onto image. guard let colorSpace = CGColorSpace(name: CGColorSpace.sRGB), let ciImage = CIImage(mtlTexture: texture, options: [.colorSpace: colorSpace]) else { return nil } // Convert CIImage to CGImage. let context = CIContext() return context.createCGImage(ciImage, from: ciImage.extent) }
0
1
247
Jan ’25
TextKit 2 Background drawing incorrect
Hi I am drawing TextKit2 managed NSAttributedStrings into a NSBitmapImageRep successfully, enumerating the Text Layout Fragments is giving me bogus background drawing This is the core drawing code, its pretty simple: I manage the flipped property myself since NSTextLayoutManager assumes a flipped coordinate. if let context = NSGraphicsContext(bitmapImageRep: self.textImageRep!) { NSGraphicsContext.current = context let rect = NSRect(origin: .zero, size: self.outputSize) NSColor.clear.set() rect.fill() // Flip the context context.cgContext.saveGState() context.cgContext.translateBy(x: 0, y: self.outputSize.height) context.cgContext.scaleBy(x: 1.0, y: -1.0) let textOrigin = CGPoint(x: 0.0, y: 0.0 ) let titleRect = CGRect(origin: textOrigin, size: self.themeTextContainer.size) NSColor.orange.withAlphaComponent(1).set() titleRect.fill() self.layoutManager.enumerateTextLayoutFragments(from: nil, using: { textLayoutFragment in // Get the fragment's rendering bounds let fragmentBounds = textLayoutFragment.layoutFragmentFrame print("fragmentBounds: \(fragmentBounds)") // Render the fragment into the context textLayoutFragment.draw(at: fragmentBounds.origin, in: context.cgContext) return true }) context.cgContext.restoreGState() } NSGraphicsContext.restoreGraphicsState() I have a mutable string which has various paragraph styles which I add to the layout manager / text storage like so let titleParagraphStyle = NSMutableParagraphStyle() titleParagraphStyle.alignment = .center titleParagraphStyle.lineBreakMode = .byWordWrapping titleParagraphStyle.lineBreakStrategy = .standard var range = NSMakeRange(0, self.attributedProgrammingBlockTitle.length) self.attributedProgrammingBlockTitle.addAttribute(.foregroundColor, value: NSColor(red: 243.0/255.0, green: 97.0/255.0, blue: 97.0/255.0, alpha: 1.0), range:range) self.attributedProgrammingBlockTitle.addAttribute(.backgroundColor, value: NSColor.cyan, range:range) self.attributedProgrammingBlockTitle.addAttribute(.font, value: NSFont.systemFont(ofSize: 64), range:range) self.attributedProgrammingBlockTitle.addAttribute(.paragraphStyle, value:titleParagraphStyle, range:range) range = NSMakeRange(0, self.attributedThemeTitle.length) self.attributedThemeTitle.addAttribute(.foregroundColor, value: NSColor.white, range:range ) self.attributedThemeTitle.addAttribute(.backgroundColor, value: NSColor.purple, range:range) self.attributedThemeTitle.addAttribute(.font, value: NSFont.systemFont(ofSize: 48), range:range) self.attributedThemeTitle.addAttribute(.paragraphStyle, value:NSParagraphStyle.default, range:range) range = NSMakeRange(0, self.attributedText.length) self.attributedText.addAttribute(.foregroundColor, value: NSColor.white, range:range ) self.attributedText.addAttribute(.backgroundColor, value: NSColor.yellow, range:range) self.attributedText.addAttribute(.font, value: NSFont.systemFont(ofSize: 36), range:range) self.attributedText.addAttribute(.paragraphStyle, value:NSParagraphStyle.default, range:range) let allText = NSMutableAttributedString() allText.append(self.attributedProgrammingBlockTitle) allText.append(NSAttributedString(string: "\n\r")) allText.append(self.attributedThemeTitle) allText.append(NSAttributedString(string: "\n\r")) allText.append(self.attributedText) self.textStorage.textStorage?.beginEditing() self.textStorage.textStorage?.setAttributedString(allText) self.textStorage.textStorage?.endEditing() self.layoutManager.ensureLayout(for: self.layoutManager.documentRange) however, i get incorrect drawing for the background color font attributes. Its origin is zero, and not correctly aligned at all with the text. How can I get correct rendering of backgrounds from TextKit2? Here is an image of my output:
3
0
481
Jan ’25
Choosing the Right Test Scope in Swift: UI, Unit, or End-to-End?
Hello, everyone! I'm currently working on creating tests for a study project in Swift. My current task is to create a test to check if a file is saved correctly. The workflow in the app is as follows: Launch the app. Open a file within the app. Modify the file. Save it inside the app. Save it to the Files app. I need to verify if the saved file in the Files app is identical to a base file stored in the app bundle. Initially, I thought I could solve this by creating a UI test, which I've already implemented up to a certain point. The UI test successfully navigates through the workflow steps until it's time to compare the saved file with the base file. The problem is that I cannot open a saved file from the Files app in a UI test because it operates in a sandboxed environment and cannot interact with external app scopes. So, my question is: What should I do in this case? Would it be better to create a unit test specifically for testing the save function and ensure the UI test only verifies if the expected filename exists in the Files app? I would prefer an end-to-end (E2E) test that covers the entire workflow, but it seems Swift splits tests into Unit and UI test groups, making this approach less straightforward. Any suggestions or best practices would be greatly appreciated!
0
2
237
Jan ’25
CATransaction commit [Crashed: com.apple.root.user-initiated-qos.cooperative]
Description We are developing a app for iOS and iPadOS that involves extensive custom drawing of paths, shapes, texts, etc. To improve drawing and rendering speed, we use CARenderer to generate cached images (CGImage) on a background thread. We adopted this approach based on this StackOverflow post: https://stackoverflow.com/a/75497329/9202699. However, we are experiencing frequent crashes in our production environment that we cannot reproduce in our development environment. Despite months of debugging and seeking support from DTS and the Apple Feedback platform, we have not been able to fully resolve this issue. Our recent crash reports indicate that the crashes occur when calling CATransaction.commit(). Crash traceback The method names in this traceback are mapped to those in the code sample below. The app name has been masked. Crashed: com.apple.root.user-initiated-qos.cooperative 0 MyApp 0x887408 specialized static CAUtils.commitCATransaction() + 4340151304 (<compiler-generated>:4340151304) 1 MyApp 0x887408 specialized static CAUtils.commitCATransaction() + 4340151304 (<compiler-generated>:4340151304) 2 MyApp 0x8874a4 specialized static CAUtils.addDrawingItemsToRenderer(***) + 250 (CAUtils.swift:250) 3 MyApp 0x887710 specialized static CAUtils.drawOnCGImageWithCARenderer(***) + 267 (CAUtils.swift:267) 4 MyApp 0x8878c0 specialized static CAUtils.drawOnCGImageWithCARendererWithRetry(***) + 315 (CAUtils.swift:315) 5 MyApp 0x736294 XXXManager.generateCGImages(***) + 570 (XXXManager.swift:570) 6 MyApp 0x73404c closure #1 in XXXManager.updateCachedCGImages(***) + 427 (XXXManager.swift:427) 7 libswift_Concurrency.dylib 0x61104 swift::runJobInEstablishedExecutorContext(swift::Job*) + 252 8 libswift_Concurrency.dylib 0x62514 swift_job_runImpl(swift::Job*, swift::SerialExecutorRef) + 144 9 libdispatch.dylib 0x15d8c _dispatch_root_queue_drain + 392 10 libdispatch.dylib 0x16590 _dispatch_worker_thread2 + 156 11 libsystem_pthread.dylib 0x4c40 _pthread_wqthread + 228 12 libsystem_pthread.dylib 0x1488 start_wqthread + 8 Code Sample Below is a sample of our code. While the complete snippet is too long, the issue occurs in addDrawingItemsToRenderer. Please refer to the other methods for completeness and reference purposes. private let transactionLock = NSLock() private let deviceLock = NSLock() private let device = MTLCreateSystemDefaultDevice()! /// This is the method we call from outside. @inline(never) static func drawOnCGImageWithCARenderer( layerRect: CGRect, drawingItems: [DrawingItem] ) -> CGImage? { guard let (texture, renderer) = addDrawingItemsToRenderer( layerRect: layerRect, drawingItems: drawingItems ) else { return nil } renderer.beginFrame(atTime: 0, timeStamp: nil) renderer.render() renderer.endFrame() guard let colorSpace = CGColorSpace(name: CGColorSpace.sRGB), let ciImage = CIImage(mtlTexture: texture, options: [.colorSpace: colorSpace]) else { return nil } let context = CIContext() return context.createCGImage(ciImage, from: ciImage.extent) } /// This is the method will the crash happens @inline(never) fileprivate static func addDrawingItemsToRenderer( layerRect: CGRect, drawingItems: [DrawingItem] ) -> (MTLTexture, CARenderer)? { // We have encapsulated everything related to CALayer and its // associated creations and manipulations within CATransaction // as suggested by engineers from Apple Feedback Portal. beginCATransaction() defer { commitCATransaction() // The crash happens here } let (layer, imageWidth, imageHeight) = addDrawingItemsToLayer(layerRect: layerRect, drawingItems: drawingItems) return createTextureAndRenderer( layer: layer, imageWidth: imageWidth, imageHeight: imageHeight ) } // Below are all internal methods. We have split the method into very // granular parts and marked them as @inline(never) to prevent the // compiler from inlining our code, which may otherwise obscure usage // trackback information in our crash reports. @inline(never) fileprivate static func beginCATransaction() { transactionLock.lock() CATransaction.begin() } @inline(never) fileprivate static func commitCATransaction() { // From our crash report, we believe the crash happens on this line. CATransaction.commit() // It is unlikely that the lock cause the crash as we added it only recently // to ensure that there is only one transaction on our background thread, // and after we added this lock, the crash rate indeed lowered, but still // not fully disappear transactionLock.unlock() } -------------------------------- // The methods below are provided for reference and completeness. While // they may have issues, they do not frequently appear in our crash // reports as the one caused by `CATransaction.commit()` @inline(never) fileprivate static func addDrawingItemsToLayer( layerRect: CGRect, drawingItems: [DrawingItem] ) -> (layer: CALayer, imageWidth: CGFloat, imageHeight: CGFloat) { let layer = CALayer() layer.isGeometryFlipped = SharedAppUtils.isIOS layer.anchorPoint = CGPoint.zero layer.bounds = layerRect layer.masksToBounds = true for drawingItem in drawingItems { // We have thousands or hundred thousands of drawing items to add. // Each drawing item may produce a CALayer, CAShapeLayer or CATextLayer. // This is also why we want to utilise CARenderer to leverage GPU rendering. let sublayerForDrawingItem = drawingItem.createCALayerOrCATextLayerOrCAShapeLayer() layer.addSublayer(sublayerForDrawingItem) } let imageWidth = max(1, layer.frame.size.width * UIScreen.main.scale) let imageHeight = max(1, layer.frame.size.height * UIScreen.main.scale) layer.transform = CATransform3DMakeScale(UIScreen.main.scale, UIScreen.main.scale, 1) layer.frame = .init(origin: .zero, size: .init(width: imageWidth, height: imageHeight)) return (layer, imageWidth, imageHeight) } @inline(never) fileprivate static func createTextureAndRenderer( layer: CALayer, imageWidth: CGFloat, imageHeight: CGFloat ) -> (MTLTexture, CARenderer)? { deviceLock.lock() defer { deviceLock.unlock() } let textureDescriptor = MTLTextureDescriptor.texture2DDescriptor( pixelFormat: .rgba8Unorm, width: Int(imageWidth), height: Int(imageHeight), mipmapped: false ) textureDescriptor.usage = [MTLTextureUsage.shaderRead, .shaderWrite, .renderTarget] guard let texture = device.makeTexture(descriptor: textureDescriptor) else { return nil } let renderer = CARenderer(mtlTexture: texture) renderer.bounds = layer.frame renderer.layer = layer.self return (texture, renderer) }
1
1
253
Jan ’25
iOS Widget can't connect to the host app and shows Skeleton.
Some of our users keep reporting that occasionally some widgets (which initially were working perfectly) are now broken and show only skeletons. Note that the app has multiple widgets, and this happens only to some of them (that is when some widgets get broken, some other widgets are still working normally). While developing the app, I came across this symptom as well, and when I read the device console, I found the following errors in the console (which the system was repeatedly reporting to the console): Unable to get connection interface: Error Domain=LNConnectionErrorDomain Code=1100 "Unable to locate com.example.app.MyAppntents for the com.apple.intents-service extension point" UserInfo={NSLocalizedDescription=Unable to locate com.example.app.MyAppIntents for the com.apple.intents-service extension point} The affected widgets use the 'UserDefaults with groups' to read the data that is stored by the host app. And I think that sometimes the widget fails (or even crashes) while reading the data from the UserDefaults and it ends up showing the skeleton. The only remedy I found was Uninstall the app Reboot the device Install the app again. After this, the widget starts to work again.. So, what can be the reason behind this? Is this an iOS bug or what and how to fight it?
2
0
218
Jan ’25
CPMapTemplate measurement units on screen
I am wondering how I change the measurement units on screen in my CPMapTemplate. In my screenshot below the distance is in miles, but how can I change that to kilometers? Does this need to come from my route data? I am not seeing this anywhere in the CarPlay programming guide or in the documentation.
1
0
259
Jan ’25
Unrealistically high snowfall amounts being reported by WeatherKit
I filed FB16332997 about the VERY high snowfall estimates I'm seeing in WeatherKit and iOS Weather. I initially thought something was wrong with my weather app but I verified the numbers with the iOS Weather app and another third party weather app. For Atlanta last week it was saying 7.5" when it ended up being 2" (which I can live with). Two days ago it reported there could be 16" of snow in northern Florida. That's impossible! This morning it was reporting that Niceville could have 6-7" of snow, which would be significantly more than highest amount in recorded history for Florida (where snow is extremely rare). It almost makes me wonder if the liquid precipitation value is actually the snowfall amount in reality. And then that is incorrectly being converted to the snowfall amount.
2
0
301
Jan ’25
Switching apps in 15.2 causes strange error
My app is the client in a client-server document management system. It supports scanning, indexing, and creation of various types documents including PDF, TIFF, various image types, and text. Upon installation of macOS 15.2, I am getting a strange NSInternalInconsistencyException error so long as the following are true: I have created or opened a PDF (or other type) document I click on the desktop/Finder or other app Normally, I would expect this action to put my App in the background, but before that happens, the error is thrown. I am not connected any server at the time. My app is built catch unhandled exceptions and this is what is displayed: At the time the error is thrown, [NSApp mainWindow] appears to be set to nil, but I have no idea if this occurred as result of becoming the background app or because of something I am doing wrong. I never set mainWindow anywhere in my app. I've tried to set a Waitchpoint or various waist try and catch when mainWindow changes, but have come up empty. Note the error is thrown if I hit a breakpoint when debugging in Xcode (because it switches to Xcode). This errors never occurred with previous releases and does not occur when the app is run under 15.1. The app is written in ObjectiveC. I've looked at various app-level flags and info.plist properties and nothing I've seen jumps out at me. I strongly suspect this error is a result of some system-level app attempting to create a UserActivity file (perhaps encrypted) that it can store in the cloud (a feature we would rather not use yet). It could also be trying to do an autosave on my open document-based windows - our NIB files that apply to our documents are marked as Restorable and they worked in prior system releases. Turning the Restorable flag off has no effect on the error. Any clue what I might be missing here? I've spent an embarrassing number of days trying to understand why this is happening.
0
0
196
Jan ’25