Test Quick Look thumbnails on a cloud Mac
When a studio delivers a document management app for macOS, a common problem is that files open correctly but show no thumbnails in the file list. A successful build on a cloud Mac proves only that the code compiles—not that Quick Look can read the file, invoke the generator, and return an image. Treating thumbnail generation as a separate acceptance task helps distinguish damaged documents, extensions that have not loaded, and session-specific behavior before delivery.
Define the test fixtures and acceptance criteria first
Prepare four types of sanitized test files: a valid single-page document, a multipage document, a document with transparent content, and a deliberately truncated, damaged document. For each type, retain the original bytes, file type, and expected result. Do not use constantly changing customer files as your baseline.
For valid samples, check whether a thumbnail is generated, whether its dimensions are reasonable, and whether expected page content is missing. Damaged samples may return an error, but must not wait indefinitely. Multipage files typically produce only a representative page, so thumbnail checks cannot replace acceptance testing of full-document rendering.
An image returned by the system does not prove that your custom thumbnail extension ran. System generators and cached results can both make an incorrect configuration appear to work.
First verify the probe with a PDF supported by the system, then switch to your app’s own file format. If generation fails, this lets you establish whether the underlying service works before investigating extension registration and drawing code at the same time.
Build a standalone thumbnail probe
The following probe takes two arguments: an input file and an output PNG. Save it as ThumbnailProbe.swift. It requests a full thumbnail representation rather than treating a file icon as a successful result. Create the output directory before running it.
import AppKit
import QuickLookThumbnailing
@main
struct ThumbnailProbe {
static func main() async throws {
guard CommandLine.arguments.count == 3 else {
throw NSError(domain: "ThumbnailProbe", code: 2)
}
let input = URL(fileURLWithPath: CommandLine.arguments[1])
let output = URL(fileURLWithPath: CommandLine.arguments[2])
let request = QLThumbnailGenerator.Request(
fileAt: input,
size: CGSize(width: 512, height: 512),
scale: 1,
representationTypes: .thumbnail
)
let image: QLThumbnailRepresentation =
try await withCheckedThrowingContinuation { continuation in
QLThumbnailGenerator.shared
.generateBestRepresentation(for: request) { result, error in
if let result {
continuation.resume(returning: result)
} else {
continuation.resume(throwing: error ?? NSError(
domain: "ThumbnailProbe", code: 3
))
}
}
}
let bitmap = NSBitmapImageRep(cgImage: image.cgImage)
guard let png = bitmap.representation(using: .png, properties: [:]) else {
throw NSError(domain: "ThumbnailProbe", code: 4)
}
try png.write(to: output, options: .atomic)
print("\(bitmap.pixelsWide)x\(bitmap.pixelsHigh)")
}
}
Compile it on macOS with the full development toolchain installed, then pass the path to an existing test document:
set -euo pipefail
mkdir -p artifacts
xcrun swiftc -parse-as-library ThumbnailProbe.swift \
-framework AppKit -framework QuickLookThumbnailing \
-o artifacts/thumbnail-probe
artifacts/thumbnail-probe \
"$PWD/fixtures/normal.pdf" \
"$PWD/artifacts/normal.png"
Do not use a semaphore on the main thread to wait synchronously for the callback. The asynchronous entry point keeps the call straightforward and helps avoid mistaking a service that has not returned for an image-encoding failure. The pipeline still needs an outer task timeout, because this probe does not implement timeout-based cancellation.
Inspect the image, not just the exit code
A successful exit means only that an image was received and written to disk. Also verify that the PNG can be decoded again, that both dimensions are greater than zero, and that its aspect ratio matches the sample’s content. The requested 512 is the target bounding size, not a requirement for square output. A portrait document should not be stretched horizontally.
Check transparency and placeholder images separately
Inspect the same PNG against both light and dark backgrounds. Transparent content may look blank on white, while faulty drawing code can produce a solid-color image with the correct dimensions. For each fixed sample, select a few stable content regions to check rather than validating only the file size.
Do not use PNG file hashes as a default pass/fail gate across operating system versions. Font rendering, antialiasing, and updates to system generators can all change pixels. Establish a visual baseline only after fixing the system and toolchain versions, and retain the original images for manual review.
Verify custom extension invocation separately
For extension acceptance testing, use a document type supported only by that extension, and draw a recognizable marker in dedicated test samples. Enable the marker only in the test configuration; do not let it appear in images delivered to customers. Then check that the containing app is installed, that file type declarations are correct, and that the extension is registered for the current user.
Run the probe first in a logged-in graphical session, then over SSH as the same user. If only the SSH run fails, record the session context and error. Do not immediately change the drawing logic or try to solve the problem by relaxing permissions across the machine.
To investigate caching, copy the same sample into a new test directory and request another thumbnail. A new path does not guarantee that every cache is bypassed. Ultimately, use the test marker and extension process logs to prove invocation; success after changing the path is not sufficient evidence on its own.
Include failure evidence in the project handover
Run each sample independently with an outer timeout, and record the exit code, elapsed time, input digest, output dimensions, and error text. On timeout, terminate the probe and check for extension tasks that are still running. Canceling the wait must not be recorded as successful generation.
Complete these checks before handover:
- Valid samples produce thumbnails with complete content regions, and damaged samples have explicit failure records.
- Multipage and transparent samples are tested separately; one valid PDF does not stand in for every format.
- Results from graphical sessions and SSH can be traced to the same user and system version.
- Custom extension invocation is backed by evidence, and baseline updates include a reason and manual confirmation.
Keep sample directories and acceptance artifacts separate for each customer project. When moving to another cloud Mac, rerun the same sanitized files before introducing real documents. This provides a comparable starting point for investigating any thumbnail problems that appear after migration.
Frequently asked questions
Does a successful thumbnail prove my custom extension loaded?
No. A system generator or cached result may supply the image. Add a test marker drawn only by your extension, then check extension registration and process logs separately.
Can the entire check run over SSH?
You can try it, but SSH is not equivalent to a graphical session. Establish a baseline in a logged-in macOS session, then compare an SSH run using the same user.
A dedicated Mac for every client project
Rent a dedicated physical Mac mini to keep each client's build environment separate. Choose daily, weekly, monthly, or quarterly billing; service stops at the end of your term unless you renew.
Rent a Mac