App was crashing in xcode 16 due to Quicklook UI framework

QLPreviewView was used in the app to display the file previews. But the following crash was happening.

Date/Time: 2024-09-13 22:03:59.056 +0530 OS Version: Mac OS X 10.13.6 (17G14042) Report Version: 12 Anonymous UUID: 7CA3750A-2BDD-3FFF-5940-E5EEAE2E55F5

Time Awake Since Boot: 4300 seconds

System Integrity Protection: disabled

Notes: Translocated Process

Crashed Thread: 0

Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY

Termination Reason: DYLD, [0x1] Library missing

Application Specific Information: dyld: launch, loading dependent libraries

Dyld Error Message: Library not loaded: /System/Library/Frameworks/QuickLookUI.framework/Versions/A/QuickLookUI Referenced from: /private/var/folders/*/Notebook (Beta).app/Contents/MacOS/Notebook (Beta) Reason: image not found

Same Problem here with with a customer running our app on macOS 11.7.10:

Process: Safe + [4989] Path: /Applications/Safe +.app/Contents/MacOS/Safe + Identifier: de.safe-app.MacOSSafe Version: 14.0.6 (14.0.602) App Item ID: 1415537597 App External ID: 869464556 Code Type: X86-64 (Native) Parent Process: ??? [1] Responsible: Safe + [4989] User ID: 501

Date/Time: 2024-10-18 13:32:34.338 +0200 OS Version: macOS 11.7.10 (20G1427) Report Version: 12 Anonymous UUID: 337E3C66-0D30-68D6-DB6A-C5B5DAA917CA

Sleep/Wake UUID: CD6604B8-2A43-44A6-9CC9-656B39B53109

Time Awake Since Boot: 93000 seconds Time Since Wake: 200 seconds

System Integrity Protection: enabled

Crashed Thread: 0

Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY

Termination Reason: DYLD, [0x1] Library missing

Application Specific Information: dyld: launch, loading dependent libraries

Dyld Error Message: dyld: Using shared cache: 3694F5E4-3E85-3CD5-A2B0-534E2DFC1355 Library not loaded: /System/Library/Frameworks/QuickLookUI.framework/Versions/A/QuickLookUI Referenced from: /Applications/Safe +.app/Contents/MacOS/Safe + Reason: image not found

Good news for devs in this thread; Xcode 16.1 (last beta) fixed this issue (at least for my app).

from macOS Sequoia 15.1 RC Release Notes

Resolved Issues Fixed: Back-deploying apps that link QuickLookUI to macOS 11 or earlier might crash. (133213738) (FB14667312)

So re-compile with Xcode 16 + macOS 15.1..and it should work

I archived our app using Xcode 16.1 and macOS 15.1, and it still crashes when it is run on macOS Ventura.

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

Termination Reason:    Namespace DYLD, Code 1 Library missing
Library not loaded: /System/iOSSupport/System/Library/Frameworks/_QuickLook_SwiftUI.framework/Versions/A/_QuickLook_SwiftUI

I am using command line tools to build a dynamic library that uses QLPreviewView and targets macOS 10.10. The API predates 10.10 (in the Quartz framework) so there should be no problem. However, even after installing Xcode 16.1, the library contains a hard link to the QuickLookUI framework, causing it to fail on macOS releases prior to macOS 12. I assume this hard link is created because in the current SDK Quartz imports QuickLookUI. I presume that the link should be a weak link.

A simple test program:

#import <Quartz/Quartz.h>

NSView *test()
{
    NSRect bounds = NSMakeRect(0, 0, 1, 1);
    QLPreviewView *preview = [[QLPreviewView alloc] initWithFrame:bounds style:QLPreviewViewStyleCompact];
    return preview;
}

The build script:

cc -target x86_64-apple-macos10.10 -dynamiclib -ObjC -framework Quartz test.m

The relevant output from otool:

Load command 9
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/Quartz.framework/Versions/A/Quartz (offset 24)
   time stamp 2 Wed Dec 31 16:00:02 1969
      current version 1.0.0
compatibility version 1.0.0

Load command 11
          cmd LC_LOAD_DYLIB
      cmdsize 96
         name /System/Library/Frameworks/QuickLookUI.framework/Versions/A/QuickLookUI (offset 24)
   time stamp 2 Wed Dec 31 16:00:02 1969
      current version 0.0.0
compatibility version 1.0.0

I was able to generate a weak link as follows:

cc -target x86_64-apple-macos10.10 -dynamiclib -ObjC -weak_framework QuickLookUI -framework Quartz test.m

I have confirmed that this fix produces a library that loads on macOS 11.

Alas, I spoke too soon.

Although adding the weak link to QuickLookUI allows the library to load on macOS 11, it does not link properly. The code fails trying to create a QLPreviewView.

A very crude and heavy-handed workaround:

  • Add a weak link to QuickLookUI as I described previously.
  • Run the executable with DYLD_FORCE_FLAT_NAMESPACE=1.

The essence of the problem is that my library compiled with recent releases of Xcode identifies QLPreviewView as belonging to the namespace assocated with QuickLookUI, but on macoS 11 and earlier, it is in the namespace associated with Quartz, so it is not found using the default two-level namespace.

Continuing my previous post here, we submitted a feedback ticket for this: FB15732009.

The crash that was posted in the original post that started this thread is slightly different than the crash I am seeing. This is the crash from the original post:

Library not loaded: /System/Library/Frameworks/QuickLookUI.framework/Versions/A/QuickLookUI

The crash I am seeing looks like this:

Library not loaded: /System/iOSSupport/System/Library/Frameworks/_QuickLook_SwiftUI.framework/Versions/A/_QuickLook_SwiftUI

The app that is crashing is using a dependency that we own and that dependency is using the quick look preview feature in SwiftUI. Which is probably why the quick look SwiftUI framework is being referenced in the crash log.

I can confirm that the problem I was having has been fixed in Xcode 16.1 and Command Line Tools 16.1. I was confused before because although Xcode 16.1 was installed, I was actually using Command Line Tools 16.0. You can tell if the library is correctly built if otool -l shows a hard link to the Quartz framework and no link to the QuickLookUI framework.

App was crashing in xcode 16 due to Quicklook UI framework
 
 
Q