Post

Replies

Boosts

Views

Activity

Xcode shows alert about unknown com.apple.quicklook.preview extension point when running on Apple Vision Pro Simulator
I have an iOS app with a QuickLook extension. I also added Apple Vision Pro in the target's General > Supported Destinations section. About one year ago, I was able to run the app on iPhone, iPad and Apple Vision Pro Simulators. Today I tried running it again on Apple Vision Pro with Xcode 26.0.1, but Xcode shows this error: Try again later. Appex bundle at ~/Library/Developer/CoreSimulator/Devices/F6B3CCA8-82FA-485F-A306-CF85FF589096/data/Library/Caches/com.apple.mobile.installd.staging/temp.PWLT59/extracted/problem.app/PlugIns/problemQuickLook.appex with id org.example.problem.problemQuickLook specifies a value (com.apple.quicklook.preview) for the NSExtensionPointIdentifier key in the NSExtension dictionary in its Info.plist that does not correspond to a known extension point. I tried again later a couple times, even after running Clean Build Folder Immediately, without any change. I can reproduce this with a fresh Xcode project to which I add a Quick Look Preview Extension and Apple Vision Pro as a supported destination. The error doesn't happen when running on Apple Vision Pro (Designed for iPad) or iPad Pro 13-inch (M4) destinations. What is the problem? I created FB20448815.
5
0
266
Nov ’25
Trying to print NSAttributedString via many UITextViews causes crash
My Mac app uses many NSTextViews just fine for printing a long string, but trying to do the same on iOS with many UITextViews and associated UIViewPrintFormatters just causes a crash.*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]' *** First throw call stack: ( 0 CoreFoundation 0x00007fff23c7127e __exceptionPreprocess + 350 1 libobjc.A.dylib 0x00007fff513fbb20 objc_exception_throw + 48 2 CoreFoundation 0x00007fff23d03ab1 _CFThrowFormattedException + 194 3 CoreFoundation 0x00007fff23b83bf9 -[__NSArrayM objectAtIndex:] + 169 4 UIKitCore 0x00007fff48029503 -[UITextViewPrintFormatter rectForPageAtIndex:] + 86 5 UIKitCore 0x00007fff4806bc79 __57-[UIPrintPageRenderer drawPrintFormatter:forPageAtIndex:]_block_invoke + 41 6 UIKitCore 0x00007fff4806bcf9 __57-[UIPrintPageRenderer drawPrintFormatter:forPageAtIndex:]_block_invoke.43 + 29 7 libdispatch.dylib 0x000000010e4f6d48 _dispatch_client_callout + 8 8 libdispatch.dylib 0x000000010e505b24 _dispatch_async_and_wait_invoke + 175 9 libdispatch.dylib 0x000000010e4f6d48 _dispatch_client_callout + 8 10 libdispatch.dylib 0x000000010e504de6 _dispatch_main_queue_callback_4CF + 1500 11 CoreFoundation 0x00007fff23bd4049 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 12 CoreFoundation 0x00007fff23bceca9 __CFRunLoopRun + 2329 13 CoreFoundation 0x00007fff23bce066 CFRunLoopRunSpecific + 438 14 GraphicsServices 0x00007fff384c0bb0 GSEventRunModal + 65 15 UIKitCore 0x00007fff48092d4d UIApplicationMain + 1621 16 myApp 0x000000010e1ca61b main + 75 17 libdyld.dylib 0x00007fff5227ec25 start + 1 18 ??? 0x0000000000000001 0x0 + 1 )Here's the code:class ViewController: UIViewController { override func viewDidAppear(_ animated: Bool) { let printController = UIPrintInteractionController.shared let printPageRenderer = PrintPageRenderer() printController.printPageRenderer = printPageRenderer printController.present(animated: true) } } class PrintPageRenderer: UIPrintPageRenderer { let layoutManager = NSLayoutManager() let textStorage = NSTextStorage(string: "fhdjksalhfj dskla fjf") var textViews = [UITextView]() override func prepare(forDrawingPages range: NSRange) { DispatchQueue.main.sync { for (i, textView) in textViews.enumerated() { let printFormatter = textView.viewPrintFormatter() addPrintFormatter(printFormatter, startingAtPageAt: i) } } } override var numberOfPages: Int { textStorage.addLayoutManager(layoutManager) let size = CGFloat(50) for _ in 0..<2 { let textContainer = NSTextContainer(size: CGSize(width: size, height: size)) layoutManager.addTextContainer(textContainer) let textView = UITextView(frame: CGRect(x: 0, y: 0, width: size, height: size), textContainer: textContainer) textViews.append(textView) } return textViews.count } }My goal is printing a document from an attributed string and showing a custom header and footer on each page.
Topic: UI Frameworks SubTopic: UIKit Tags:
9
0
2k
Jul ’22
Resolve bookmark created in iOS app in Share Extension
I create a URL bookmark with `URL.bookmarkData(options: [], includingResourceValuesForKeys: [.localizedNameKey])` and resolve it with `NSURL(resolvingBookmarkData: bookmarkData, options: [], relativeTo: nil, bookmarkDataIsStale: nil) as URL`. This works fine within my main app, but when sharing the bookmarkData via an App Group with my Share Extension, it gives the error "The file couldn't be opened because you don't have permission to view it.". Is there any way I can do this?
Topic: UI Frameworks SubTopic: UIKit Tags:
4
0
1.2k
Jan ’21
How to download and install old macOS versions
I haven‘t yet found an official Apple website that lists older macOS versions. Fortunately, I have kept the installers on a separate external storage after each major upgrade, but when launching them from a macOS version newer that the installer itself, macOS shows an error that it‘s not possible to install it. What is the official way of installing older macOS versions so that I can test my App Store apps?
4
0
3.5k
Nov ’21
How to install macOS 14 Sonoma or 13 Ventura on an external partition
I would like to install macOS 14 Sonoma on an external partition, but I couldn't find an installer on the developer website. It seems that it's only possible to upgrade from the System Settings, so I thought I would install Ventura first on the separate partition and then upgrade to Sonoma. I downloaded the Ventura installer from the App Store and selected the external partition during the installation, but when the Mac reboots, it just reboots into my main macOS partition. If I shut down and hold the power button pressed to select the boot partition (I have a M1 MacBook Pro 14" 2022), then nothing happens: an indeterminate progress indicator spins for a couple seconds, the partition list remains there and I can only successfully boot into my main partition again. I also tried running the installer from another macOS Ventura and macOS Monterey partition I had installed last year, but when I select the partition on which to install the new Ventura, nothing happens and I can only quit the installer. Is there a way to debug all these issues? How can I install macOS Sonoma on a separate partition without overwriting my main macOS Ventura install?
4
2
4.0k
Jun ’23
FileManager.containerURL(forSecurityApplicationGroupIdentifier:) returns nil on macOS
I keep getting crash reports in Xcode for one of my macOS apps published on the App Store. Actually it's not the main app that crashes, but the embedded Finder Sync extension. The crash reports indicate that this source code line static var appGroupSaveDirectoryUrl = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: identifier)!.appendingPathComponent("Library/Application Support/somedata") crashes with error Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value + 0 (<compiler-generated>:0) That line is a static variable defined in a class that is included in the main app as well as the Finder extension. The documentation reads In iOS, the value is nil when the group identifier is invalid. In macOS, a URL of the expected form is always returned, even if the app group is invalid If the documentation says that the method call can never be nil, why am I getting this crash? Is it a bug or is the documentation wrong, or am I doing something wrong? And why does the Finder Sync extension crash and not the main app? I cannot reproduce this crash with the App Store app or within Xcode and Console shows no crash reports for the app on my Mac.
4
0
1.5k
Oct ’23
Get Application Scripts directory for app group
For the current app, I can get the Application Scripts directory with FileManager.url(for: .applicationScriptsDirectory, in: .userDomainMask, appropriateFor: nil, create: true), but I cannot find a similar API for application groups. Does one exist, or do I have to construct the URL manually? That would probably be ~/Library/Application Scripts/[app group id], but there doesn't seem to be a FileManager API to access ~ either, as FileManager.default.homeDirectoryForCurrentUser returns /Users/username/Library/Containers/[app id]/Data/.
4
0
721
Feb ’24
SwiftUI ShareLink doesn't show option "Copy" when sharing text
With a Button I can directly copy contents to the clipboard via UIPasteboard.general.setObjects(objects), but this is iOS-specific so I was hoping that ShareLink would allow me to share items in a platform-independent way. Is it possible to show a Copy item in the ShareLink sheet? import SwiftUI struct ContentView: View { let myType = MyType() var body: some View { ShareLink(item: myType, preview: SharePreview(myType.text)) } } class MyType: Transferable { let text = "asdf" static var transferRepresentation: some TransferRepresentation { ProxyRepresentation { myType in return myType.text } } } #Preview { ContentView() }
4
1
976
Jun ’24
GKMatch.chooseBestHostingPlayer(_:) always returns nil player
I'm building a game with a client-server architecture. Using GKMatch.chooseBestHostingPlayer(_:) rarely works. When I started testing it today, it worked once at the very beginning, and since then it always succeeds on one client and returns nil on the other client. I'm testing with a Mac and an iPhone. Sometimes it fails on the Mac, sometimes on the iPhone. On the device that it succeeds on, the provided host can be the device itself or the other one. I created FB9583628 in August 2021, but after the Feedback Assistant team replied that they are not able to reproduce it, the feedback never went forward. import SceneKit import GameKit #if os(macOS) typealias ViewController = NSViewController #else typealias ViewController = UIViewController #endif class GameViewController: ViewController, GKMatchmakerViewControllerDelegate, GKMatchDelegate { var match: GKMatch? var matchStarted = false override func viewDidLoad() { super.viewDidLoad() GKLocalPlayer.local.authenticateHandler = authenticate } private func authenticate(_ viewController: ViewController?, _ error: Error?) { #if os(macOS) if let viewController = viewController { presentAsSheet(viewController) } else if let error = error { print(error) } else { print("authenticated as \(GKLocalPlayer.local.gamePlayerID)") let viewController = GKMatchmakerViewController(matchRequest: defaultMatchRequest())! viewController.matchmakerDelegate = self GKDialogController.shared().present(viewController) } #else if let viewController = viewController { present(viewController, animated: true) } else if let error = error { print(error) } else { print("authenticated as \(GKLocalPlayer.local.gamePlayerID)") let viewController = GKMatchmakerViewController(matchRequest: defaultMatchRequest())! viewController.matchmakerDelegate = self present(viewController, animated: true) } #endif } private func defaultMatchRequest() -> GKMatchRequest { let request = GKMatchRequest() request.minPlayers = 2 request.maxPlayers = 2 request.defaultNumberOfPlayers = 2 request.inviteMessage = "Ciao!" return request } func matchmakerViewControllerWasCancelled(_ viewController: GKMatchmakerViewController) { print("cancelled") } func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFailWithError error: Error) { print(error) } func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFind match: GKMatch) { self.match = match match.delegate = self startMatch() } func match(_ match: GKMatch, player: GKPlayer, didChange state: GKPlayerConnectionState) { print("\(player.gamePlayerID) changed state to \(String(describing: state))") startMatch() } func startMatch() { let match = match! if matchStarted || match.expectedPlayerCount > 0 { return } print("starting match with local player \(GKLocalPlayer.local.gamePlayerID) and remote players \(match.players.map({ $0.gamePlayerID }))") match.chooseBestHostingPlayer { host in print("host is \(String(describing: host?.gamePlayerID))") } } }
4
0
349
Apr ’25
Printing NSTextStorage over multiple UITextView produces weird results
I would like to print a NSTextStorage on multiple pages and add annotations to the side margins corresponding to certain text ranges. For example, for all occurrences of # at the start of a line, the side margin should show an automatically increasing number. My idea was to create a NSLayoutManager and dynamically add NSTextContainer instances to it until all text is laid out. The layoutManager would then allow me to get the bounding rectangle of the interesting text ranges so that I can draw the corresponding numbers at the same height inside the side margin. This approach works well on macOS, but I'm having some issues on iOS. When running the code below in an iPad Simulator, I would expect that the print preview shows 3 pages, the first with the numbers 0-1, the second with the numbers 2-3, and the last one with the number 4. Instead the first page shows the number 4, the second one the numbers 2-4, and the last one the numbers 0-4. It's as if the pages are inverted, and each page shows the text starting at the correct location but always ending at the end of the complete text (and not the range assigned to the relative textContainer). I've created FB17026419. class ViewController: UIViewController { override func viewDidAppear(_ animated: Bool) { let printController = UIPrintInteractionController.shared let printPageRenderer = PrintPageRenderer() printPageRenderer.pageSize = CGSize(width: 100, height: 100) printPageRenderer.textStorage = NSTextStorage(string: (0..<5).map({ "\($0)" }).joined(separator: "\n"), attributes: [.font: UIFont.systemFont(ofSize: 30)]) printController.printPageRenderer = printPageRenderer printController.present(animated: true) { _, _, error in if let error = error { print(error.localizedDescription) } } } } class PrintPageRenderer: UIPrintPageRenderer, NSLayoutManagerDelegate { var pageSize: CGSize! var textStorage: NSTextStorage! private let layoutManager = NSLayoutManager() private var textViews = [UITextView]() override var numberOfPages: Int { if !Thread.isMainThread { return DispatchQueue.main.sync { [self] in numberOfPages } } printFormatters = nil layoutManager.delegate = self textStorage.addLayoutManager(layoutManager) if textStorage.length > 0 { let glyphRange = layoutManager.glyphRange(forCharacterRange: NSRange(location: textStorage.length - 1, length: 0), actualCharacterRange: nil) layoutManager.textContainer(forGlyphAt: glyphRange.location, effectiveRange: nil) } var page = 0 for textView in textViews { let printFormatter = textView.viewPrintFormatter() addPrintFormatter(printFormatter, startingAtPageAt: page) page += printFormatter.pageCount } return page } func layoutManager(_ layoutManager: NSLayoutManager, didCompleteLayoutFor textContainer: NSTextContainer?, atEnd layoutFinishedFlag: Bool) { if textContainer == nil { addPage() } } private func addPage() { let textContainer = NSTextContainer(size: pageSize) layoutManager.addTextContainer(textContainer) let textView = UITextView(frame: CGRect(origin: .zero, size: pageSize), textContainer: textContainer) textViews.append(textView) } }
Topic: UI Frameworks SubTopic: UIKit Tags:
4
0
106
Apr ’25
NSTableView.clickedRow sometimes is greater than number of rows
Xcode has been downloading many similar crash reports for my app for some time now, related to an index out of range runtime exception when accessing a Swift array. The crashes always happen in methods triggered by user input or during menu item validation when I try to access the data source array by using the following code to determine the indexes of the relevant table rows: let indexes = clickedRow == -1 || selectedRowIndexes.contains(clickedRow) ? selectedRowIndexes : IndexSet(integer: clickedRow) I was never able to reproduce the crash until today. When the app crashed in the Xcode debugger, I examined the variables clickedRow and selectedRowIndexes.first, which were 1 and 0 respectively. What's interesting: the table view only contained one row, so clickedRow was effectively invalid. I tried to reproduce the issue several times afterwards, but it never happened again. What could cause this issue? What are the circumstances where it is invalid? Do I always have to explicitly check if clickedRow is within the data source range?
Topic: UI Frameworks SubTopic: AppKit Tags:
4
0
80
Apr ’25
Overriding NSDocument.prepareSavePanel(_:) hides file format popup button
I would like to provide a default filename when saving a document depending on the document data. I thought I could do so by overriding NSDocument.prepareSavePanel(_:) and setting NSSavePanel.nameFieldStringValue, but simply implementing that method seems to hide the file format popup button shown by default (see image). Calling super doesn't help. Is it possible to set a default filename and keep the file format popup button? On macOS 15, I can toggle NSSavePanel.showsContentTypes, but how about macOS 14 and older?
Topic: UI Frameworks SubTopic: AppKit Tags:
4
0
89
Apr ’25