Swift 5.9 and PDFKit JIT session error w/symbol dump
The following code works correctly in a Swift Playground created by Xcode 14.3.1 or Xcode 15. It outputs the page count of the one-page test pdf as 1.
import Foundation
import PDFKit
let test_PDF = ("~/Desktop/test.pdf" as NSString).expandingTildeInPath
let test_URL = NSURL.init(fileURLWithPath:test_PDF) as URL
let pdf = PDFDocument(url:test_URL)!
print(pdf.pageCount)
However, the same code outside of either Playground fails with a JIT session error: Symbols not found: when run as an interpreted (#!/usr/bin/swift) or compiled solution on Ventura 13.5.2 or 13.6 with the command line tools for Xcode 15 installed - which introduced Swift 5.9. Earlier versions of Swift worked correctly with the same code above.
I discovered that the workaround for this JIT Error and an error free execution was to make the following change:
import PDFKit
with:
import Quartz.PDFKit
or even just Quartz.
Mac mini (M2, 2023)