|
| 1 | +diff --git a/ios/RNPDFPdf/HybridPdfDocument.swift b/ios/RNPDFPdf/HybridPdfDocument.swift |
| 2 | +--- a/ios/RNPDFPdf/HybridPdfDocument.swift |
| 3 | ++++ b/ios/RNPDFPdf/HybridPdfDocument.swift |
| 4 | +@@ -800,9 +800,13 @@ enum HybridPdfShared { |
| 5 | + } |
| 6 | + |
| 7 | + /// Lookup for RNPDFPdfPageView.mm, which cannot import the Swift module header. |
| 8 | ++/// Must stay internal and C-typed: public declarations are emitted into NitroPdfJsi-Swift.h, |
| 9 | ++/// which Nitro includes from plain C++ where Objective-C types do not exist. |
| 10 | ++/// Returns a +1 retained PDFDocument; the caller takes ownership with __bridge_transfer. |
| 11 | + @_cdecl("RNPDFSharedDocument") |
| 12 | +-public func RNPDFSharedDocument(_ path: NSString) -> PDFDocument? { |
| 13 | +- HybridPdfShared.find(path as String) |
| 14 | ++func RNPDFSharedDocument(_ path: UnsafePointer<CChar>) -> UnsafeMutableRawPointer? { |
| 15 | ++ guard let document = HybridPdfShared.find(String(cString: path)) else { return nil } |
| 16 | ++ return Unmanaged.passRetained(document).toOpaque() |
| 17 | + } |
| 18 | + |
| 19 | + enum HybridPdfPaths { |
| 20 | +diff --git a/ios/RNPDFPdf/RNPDFPdfPageView.mm b/ios/RNPDFPdf/RNPDFPdfPageView.mm |
| 21 | +--- a/ios/RNPDFPdf/RNPDFPdfPageView.mm |
| 22 | ++++ b/ios/RNPDFPdf/RNPDFPdfPageView.mm |
| 23 | +@@ -10,8 +10,8 @@ |
| 24 | + |
| 25 | + using namespace facebook::react; |
| 26 | + |
| 27 | +-/// Defined in HybridPdfDocument.swift. |
| 28 | +-extern "C" PDFDocument *_Nullable RNPDFSharedDocument(NSString *path); |
| 29 | ++/// Defined in HybridPdfDocument.swift. Returns a +1 retained PDFDocument or NULL. |
| 30 | ++extern "C" void *_Nullable RNPDFSharedDocument(const char *path); |
| 31 | + |
| 32 | + @interface RNPDFPdfPageView () <RCTRNPDFPdfPageViewViewProtocol> |
| 33 | + @end |
| 34 | +@@ -89,7 +89,8 @@ - (void)render |
| 35 | + BOOL annotations = _annotations; |
| 36 | + CGFloat screenScale = self.traitCollection.displayScale > 0 ? self.traitCollection.displayScale : 2; |
| 37 | + dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{ |
| 38 | +- PDFDocument *document = RNPDFSharedDocument(path); |
| 39 | ++ void *raw = RNPDFSharedDocument(path.UTF8String); |
| 40 | ++ PDFDocument *document = raw ? (__bridge_transfer PDFDocument *)raw : nil; |
| 41 | + NSString *code = nil; |
| 42 | + NSString *message = nil; |
| 43 | + UIImage *image = nil; |
0 commit comments