From f56bd1cdb0b5805403ae97fcec92ad0120206968 Mon Sep 17 00:00:00 2001
From: Paul Schmiedmayer
Date: Fri, 28 Jun 2024 19:30:40 -0700
Subject: [PATCH 1/4] Initial visionOS Support
---
.github/workflows/tests.yml | 10 +++-
.gitignore | 1 +
.../Example_iOS-SPM.xcodeproj/project.pbxproj | 10 ++++
Shared iOS/Assets/Base.lproj/Main.storyboard | 54 +++++++++++--------
Shared iOS/UI/ViewController.swift | 5 +-
.../DocumentSettingsExampleFactory.swift | 2 +-
Shared/Examples/GroupExampleFactory.swift | 2 +-
Shared/Examples/ImageExampleFactory.swift | 2 +-
.../LineSeparatorExampleFactory.swift | 2 +-
Shared/Examples/MetadataExampleFactory.swift | 2 +-
.../Examples/MultiSectionExampleFactory.swift | 2 +-
.../ObjectAttributesExampleFactory.swift | 2 +-
.../Examples/PaginationExampleFactory.swift | 2 +-
Shared/Examples/TableExampleFactory.swift | 2 +-
.../TableOfContentsExampleFactory.swift | 2 +-
Shared/Examples/TextExampleFactory.swift | 2 +-
.../Examples/TextStylesExampleFactory.swift | 2 +-
Source/API/Document/PDFDocument.swift | 2 +-
.../API/Graphics/PDFBezierPath+Copying.swift | 2 +-
Source/API/Graphics/PDFBezierPath.swift | 10 ++--
Source/API/Graphics/PDFBezierPathVertex.swift | 2 +-
.../Graphics/PDFDynamicGeometryShape.swift | 2 +-
Source/API/Graphics/PDFLineStyle.swift | 2 +-
Source/API/Groups/PDFGroup+Objects.swift | 2 +-
Source/API/Groups/PDFGroup.swift | 2 +-
Source/API/Groups/PDFMasterGroup.swift | 2 +-
Source/API/Image/PDFImage.swift | 2 +-
Source/API/Layout/PDFPageLayout.swift | 2 +-
Source/API/List/PDFList.swift | 2 +-
Source/API/Metadata/PDFInfo.swift | 2 +-
Source/API/PDFGenerator+Generation.swift | 2 +-
Source/API/PDFGenerator.swift | 2 +-
Source/API/PDFMultiDocumentGenerator.swift | 2 +-
.../Page Format/PDFPageFormat+Layout.swift | 2 +-
.../PDFPageFormat+NameConstants.swift | 2 +-
.../PDFPageFormat+SizeConstants.swift | 2 +-
Source/API/Page Format/PDFPageFormat.swift | 2 +-
Source/API/Pagination/PDFPagination.swift | 2 +-
Source/API/Section/PDFSection.swift | 2 +-
Source/API/Section/PDFSectionColumn.swift | 2 +-
.../API/Table/Content/PDFTableContent.swift | 2 +-
.../Content/UIImage+PDFTableContent.swift | 2 +-
Source/API/Table/PDFTable.swift | 2 +-
.../API/Table/Style/PDFTableCellStyle.swift | 2 +-
.../Table/Style/PDFTableStyle+Defaults.swift | 2 +-
Source/API/Text/PDFAttributedText.swift | 2 +-
Source/API/Text/PDFSimpleText.swift | 2 +-
Source/API/Text/PDFTextStyle.swift | 2 +-
Source/API/Utils/CrossPlattformGraphics.swift | 2 +-
Source/API/Utils/PDFRenderObject.swift | 2 +-
.../External/PDFExternalPageObject.swift | 2 +-
.../Graphics/PDFContextGraphics.swift | 2 +-
Source/Internal/Graphics/PDFGraphics.swift | 14 ++---
Source/Internal/Graphics/PDFLineObject.swift | 2 +-
.../Graphics/PDFLineSeparatorObject.swift | 2 +-
.../Graphics/PDFRectangleObject.swift | 2 +-
.../Graphics/UIColor+CloseToEqual.swift | 2 +-
Source/Internal/Group/PDFGroupObject.swift | 4 +-
Source/Internal/Image/PDFImageObject.swift | 4 +-
Source/Internal/Image/PDFImageRowObject.swift | 2 +-
.../Layout/PDFColumnLayoutState.swift | 2 +-
.../Layout/PDFIndentationObject.swift | 2 +-
Source/Internal/Layout/PDFLayout.swift | 2 +-
Source/Internal/Layout/PDFLayoutHeights.swift | 2 +-
.../Layout/PDFLayoutIndentations.swift | 2 +-
Source/Internal/Layout/PDFMarginObject.swift | 2 +-
Source/Internal/Layout/PDFOffsetObject.swift | 2 +-
.../Internal/Layout/PDFPageBreakObject.swift | 2 +-
Source/Internal/Layout/PDFSpaceObject.swift | 2 +-
Source/Internal/Math/CGPoint+Math.swift | 2 +-
Source/Internal/Math/CGPoint+Null.swift | 2 +-
Source/Internal/PDFGenerator+Debug.swift | 2 +-
Source/Internal/PDFGenerator+Layout.swift | 2 +-
.../Section/PDFColumnWrapSectionObject.swift | 2 +-
.../Internal/Section/PDFSectionObject.swift | 2 +-
Source/Internal/Table/PDFTableObject.swift | 2 +-
Source/Internal/Table/PDFTableValidator.swift | 2 +-
.../Text/PDFAttributedTextObject.swift | 2 +-
Source/Internal/Text/PDFFontObject.swift | 2 +-
Source/Internal/Text/PDFTextColorObject.swift | 2 +-
Source/Internal/Utils/PDFCalculations.swift | 2 +-
Source/Internal/Utils/PDFSlicedObject.swift | 2 +-
.../Internal/Table/PDFTableObjectSpec.swift | 2 +-
83 files changed, 145 insertions(+), 115 deletions(-)
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 0fd86ce9a..051e9d741 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -16,6 +16,12 @@ jobs:
name: iOS Unit Tests
runs-on: macos-14
timeout-minutes: 30
+ strategy:
+ matrix:
+ build: [
+ { sdk: 'iphonesimulator', destination: 'platform=iOS Simulator,OS=17.5,name=iPhone 15 Pro' },
+ { sdk: 'xros', destination: 'platform=visionOS Simulator,OS=1.2,name=Apple Vision Pro' }
+ ]
steps:
- # Checkout the repository
uses: actions/checkout@v4
@@ -27,8 +33,8 @@ jobs:
env NSUnbufferedIO=YES \
xcodebuild -workspace . \
-scheme "TPPDF" \
- -sdk iphonesimulator \
- -destination "OS=17.4,name=iPhone 15 Pro" \
+ -sdk "${{ matrix.build.sdk }}" \
+ -destination "${{ matrix.build.destination }}" \
-configuration Debug \
-enableCodeCoverage YES \
-derivedDataPath /tmp/DerivedData \
diff --git a/.gitignore b/.gitignore
index 5fe4d8405..2ee24998c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@
## Build generated
build/
DerivedData
+test.log
## Various settings
*.pbxuser
diff --git a/Example iOS-SwiftPM/Example_iOS-SPM.xcodeproj/project.pbxproj b/Example iOS-SwiftPM/Example_iOS-SPM.xcodeproj/project.pbxproj
index 75815d455..f13fcb71b 100644
--- a/Example iOS-SwiftPM/Example_iOS-SPM.xcodeproj/project.pbxproj
+++ b/Example iOS-SwiftPM/Example_iOS-SPM.xcodeproj/project.pbxproj
@@ -532,7 +532,12 @@
PRODUCT_BUNDLE_IDENTIFIER = com.techprimate.tppdf.example;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
+ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
+ SUPPORTS_MACCATALYST = NO;
+ SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,7";
+ XROS_DEPLOYMENT_TARGET = 1.0;
};
name = Debug;
};
@@ -557,7 +562,12 @@
PRODUCT_BUNDLE_IDENTIFIER = com.techprimate.tppdf.example;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
+ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
+ SUPPORTS_MACCATALYST = NO;
+ SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,7";
+ XROS_DEPLOYMENT_TARGET = 1.0;
};
name = Release;
};
diff --git a/Shared iOS/Assets/Base.lproj/Main.storyboard b/Shared iOS/Assets/Base.lproj/Main.storyboard
index e6705b719..dc08e690d 100644
--- a/Shared iOS/Assets/Base.lproj/Main.storyboard
+++ b/Shared iOS/Assets/Base.lproj/Main.storyboard
@@ -1,16 +1,16 @@
-
+
-
-
+
+
-
+
@@ -19,33 +19,37 @@
-
-
+
+
-
+
+
+
+
+
-
+
-
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
@@ -55,11 +59,11 @@
-
+
-
+
@@ -99,7 +103,7 @@
-
+
@@ -112,4 +116,12 @@
+
+
+
+
+
+
+
+
diff --git a/Shared iOS/UI/ViewController.swift b/Shared iOS/UI/ViewController.swift
index 440689d70..a25d9053b 100644
--- a/Shared iOS/UI/ViewController.swift
+++ b/Shared iOS/UI/ViewController.swift
@@ -8,9 +8,10 @@
import TPPDF
import UIKit
+import WebKit
class ViewController: UIViewController {
- @IBOutlet var webView: UIWebView!
+ @IBOutlet var webView: WKWebView!
@IBOutlet var progressView: UIProgressView!
var progressObserver: NSObjectProtocol!
@@ -62,7 +63,7 @@ class ViewController: UIViewController {
DispatchQueue.main.async {
self.progressView.isHidden = true
// Load PDF into a webview from the temporary file
- self.webView.loadRequest(URLRequest(url: url))
+ self.webView.load(URLRequest(url: url))
}
} catch {
print("Error while generating PDF: " + error.localizedDescription)
diff --git a/Shared/Examples/DocumentSettingsExampleFactory.swift b/Shared/Examples/DocumentSettingsExampleFactory.swift
index bf4bc5c5e..02bf058c7 100644
--- a/Shared/Examples/DocumentSettingsExampleFactory.swift
+++ b/Shared/Examples/DocumentSettingsExampleFactory.swift
@@ -6,7 +6,7 @@
// Copyright © 2021 techprimate GmbH & Co. KG. All rights reserved.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Shared/Examples/GroupExampleFactory.swift b/Shared/Examples/GroupExampleFactory.swift
index 95cd1ec8e..93681abcc 100644
--- a/Shared/Examples/GroupExampleFactory.swift
+++ b/Shared/Examples/GroupExampleFactory.swift
@@ -6,7 +6,7 @@
// Copyright © 2022 techprimate GmbH. All rights reserved.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Shared/Examples/ImageExampleFactory.swift b/Shared/Examples/ImageExampleFactory.swift
index c1d0fb7a7..7b38ffd94 100644
--- a/Shared/Examples/ImageExampleFactory.swift
+++ b/Shared/Examples/ImageExampleFactory.swift
@@ -6,7 +6,7 @@
// Copyright © 2022 techprimate GmbH. All rights reserved.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Shared/Examples/LineSeparatorExampleFactory.swift b/Shared/Examples/LineSeparatorExampleFactory.swift
index 39c413911..e67367c4f 100644
--- a/Shared/Examples/LineSeparatorExampleFactory.swift
+++ b/Shared/Examples/LineSeparatorExampleFactory.swift
@@ -6,7 +6,7 @@
// Copyright © 2022 techprimate GmbH. All rights reserved.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Shared/Examples/MetadataExampleFactory.swift b/Shared/Examples/MetadataExampleFactory.swift
index e68c622b9..b2ef7dff8 100644
--- a/Shared/Examples/MetadataExampleFactory.swift
+++ b/Shared/Examples/MetadataExampleFactory.swift
@@ -6,7 +6,7 @@
// Copyright © 2022 techprimate GmbH. All rights reserved.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Shared/Examples/MultiSectionExampleFactory.swift b/Shared/Examples/MultiSectionExampleFactory.swift
index 789a3af35..80b79cb8d 100644
--- a/Shared/Examples/MultiSectionExampleFactory.swift
+++ b/Shared/Examples/MultiSectionExampleFactory.swift
@@ -7,7 +7,7 @@
//
import TPPDF
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Shared/Examples/ObjectAttributesExampleFactory.swift b/Shared/Examples/ObjectAttributesExampleFactory.swift
index 32c9fd558..425ff5cab 100644
--- a/Shared/Examples/ObjectAttributesExampleFactory.swift
+++ b/Shared/Examples/ObjectAttributesExampleFactory.swift
@@ -6,7 +6,7 @@
// Copyright © 2022 techprimate GmbH. All rights reserved.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Shared/Examples/PaginationExampleFactory.swift b/Shared/Examples/PaginationExampleFactory.swift
index 3967f8b2c..ecc5733ec 100644
--- a/Shared/Examples/PaginationExampleFactory.swift
+++ b/Shared/Examples/PaginationExampleFactory.swift
@@ -6,7 +6,7 @@
// Copyright © 2022 techprimate GmbH. All rights reserved.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Shared/Examples/TableExampleFactory.swift b/Shared/Examples/TableExampleFactory.swift
index c87e6d663..99cff9f77 100644
--- a/Shared/Examples/TableExampleFactory.swift
+++ b/Shared/Examples/TableExampleFactory.swift
@@ -6,7 +6,7 @@
// Copyright © 2022 techprimate GmbH. All rights reserved.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Shared/Examples/TableOfContentsExampleFactory.swift b/Shared/Examples/TableOfContentsExampleFactory.swift
index 85eaa24c4..81413a7f5 100644
--- a/Shared/Examples/TableOfContentsExampleFactory.swift
+++ b/Shared/Examples/TableOfContentsExampleFactory.swift
@@ -6,7 +6,7 @@
// Copyright © 2022 techprimate GmbH. All rights reserved.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Shared/Examples/TextExampleFactory.swift b/Shared/Examples/TextExampleFactory.swift
index fff1fc746..1593899cc 100644
--- a/Shared/Examples/TextExampleFactory.swift
+++ b/Shared/Examples/TextExampleFactory.swift
@@ -6,7 +6,7 @@
// Copyright © 2022 techprimate GmbH. All rights reserved.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Shared/Examples/TextStylesExampleFactory.swift b/Shared/Examples/TextStylesExampleFactory.swift
index bedca7501..0bb6b264c 100644
--- a/Shared/Examples/TextStylesExampleFactory.swift
+++ b/Shared/Examples/TextStylesExampleFactory.swift
@@ -6,7 +6,7 @@
// Copyright © 2022 techprimate GmbH. All rights reserved.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Document/PDFDocument.swift b/Source/API/Document/PDFDocument.swift
index a1e34f954..352c84adc 100644
--- a/Source/API/Document/PDFDocument.swift
+++ b/Source/API/Document/PDFDocument.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 12/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Graphics/PDFBezierPath+Copying.swift b/Source/API/Graphics/PDFBezierPath+Copying.swift
index 75561e91f..de553b253 100644
--- a/Source/API/Graphics/PDFBezierPath+Copying.swift
+++ b/Source/API/Graphics/PDFBezierPath+Copying.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 03.06.19.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Graphics/PDFBezierPath.swift b/Source/API/Graphics/PDFBezierPath.swift
index 73375e047..605d163d6 100644
--- a/Source/API/Graphics/PDFBezierPath.swift
+++ b/Source/API/Graphics/PDFBezierPath.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 01.06.19.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
@@ -198,13 +198,13 @@ public class PDFBezierPath: CustomStringConvertible {
case let .move(point):
bezierPath.move(to: calculate(point: point, in: frame))
case let .line(point):
- #if os(iOS)
+ #if os(iOS) || os(visionOS)
bezierPath.addLine(to: calculate(point: point, in: frame))
#else
bezierPath.line(to: calculate(point: point, in: frame))
#endif
case let .curve(endPoint, controlPoint1, controlPoint2):
- #if os(iOS)
+ #if os(iOS) || os(visionOS)
bezierPath.addCurve(
to: calculate(point: endPoint, in: frame),
controlPoint1: calculate(point: controlPoint1, in: frame),
@@ -218,7 +218,7 @@ public class PDFBezierPath: CustomStringConvertible {
)
#endif
case let .quadCurve(endPoint, controlPoint):
- #if os(iOS)
+ #if os(iOS) || os(visionOS)
bezierPath.addQuadCurve(
to: calculate(point: endPoint, in: frame),
controlPoint: calculate(point: controlPoint, in: frame)
@@ -230,7 +230,7 @@ public class PDFBezierPath: CustomStringConvertible {
)
#endif
case let .arc(center, radius, startAngle, endAngle, clockwise):
- #if os(iOS)
+ #if os(iOS) || os(visionOS)
bezierPath.addArc(
withCenter: calculate(point: center, in: frame),
radius: radius,
diff --git a/Source/API/Graphics/PDFBezierPathVertex.swift b/Source/API/Graphics/PDFBezierPathVertex.swift
index 3e99cd78a..1d69a44de 100644
--- a/Source/API/Graphics/PDFBezierPathVertex.swift
+++ b/Source/API/Graphics/PDFBezierPathVertex.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 01.06.19.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Graphics/PDFDynamicGeometryShape.swift b/Source/API/Graphics/PDFDynamicGeometryShape.swift
index 5846b41df..57b31511b 100644
--- a/Source/API/Graphics/PDFDynamicGeometryShape.swift
+++ b/Source/API/Graphics/PDFDynamicGeometryShape.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 01.06.19.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Graphics/PDFLineStyle.swift b/Source/API/Graphics/PDFLineStyle.swift
index 2bb95029d..7091af267 100644
--- a/Source/API/Graphics/PDFLineStyle.swift
+++ b/Source/API/Graphics/PDFLineStyle.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 11/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Groups/PDFGroup+Objects.swift b/Source/API/Groups/PDFGroup+Objects.swift
index b40eebfb0..d21497d42 100644
--- a/Source/API/Groups/PDFGroup+Objects.swift
+++ b/Source/API/Groups/PDFGroup+Objects.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 31.05.19.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Groups/PDFGroup.swift b/Source/API/Groups/PDFGroup.swift
index 06a974052..1c39f38b6 100644
--- a/Source/API/Groups/PDFGroup.swift
+++ b/Source/API/Groups/PDFGroup.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 31.05.19.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Groups/PDFMasterGroup.swift b/Source/API/Groups/PDFMasterGroup.swift
index 09221f5c7..da4742a3d 100644
--- a/Source/API/Groups/PDFMasterGroup.swift
+++ b/Source/API/Groups/PDFMasterGroup.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 31.05.19.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Image/PDFImage.swift b/Source/API/Image/PDFImage.swift
index 784aa8940..177757676 100644
--- a/Source/API/Image/PDFImage.swift
+++ b/Source/API/Image/PDFImage.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 11/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Layout/PDFPageLayout.swift b/Source/API/Layout/PDFPageLayout.swift
index f5f2c1949..117738613 100644
--- a/Source/API/Layout/PDFPageLayout.swift
+++ b/Source/API/Layout/PDFPageLayout.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 11/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/List/PDFList.swift b/Source/API/List/PDFList.swift
index bc6f0d88a..f48551cea 100644
--- a/Source/API/List/PDFList.swift
+++ b/Source/API/List/PDFList.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 13/06/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Metadata/PDFInfo.swift b/Source/API/Metadata/PDFInfo.swift
index 3fac4a899..5f6fcf6b6 100644
--- a/Source/API/Metadata/PDFInfo.swift
+++ b/Source/API/Metadata/PDFInfo.swift
@@ -5,7 +5,7 @@
// Created by Zheng-Xiang Ke on 2016/12/15.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/PDFGenerator+Generation.swift b/Source/API/PDFGenerator+Generation.swift
index fa9a03f99..2b70e7025 100644
--- a/Source/API/PDFGenerator+Generation.swift
+++ b/Source/API/PDFGenerator+Generation.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 05/06/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/PDFGenerator.swift b/Source/API/PDFGenerator.swift
index 29e3c442c..bab290109 100644
--- a/Source/API/PDFGenerator.swift
+++ b/Source/API/PDFGenerator.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 11/08/16.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/PDFMultiDocumentGenerator.swift b/Source/API/PDFMultiDocumentGenerator.swift
index 77fc801b9..a2bcaf54b 100644
--- a/Source/API/PDFMultiDocumentGenerator.swift
+++ b/Source/API/PDFMultiDocumentGenerator.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 04.12.2019
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Page Format/PDFPageFormat+Layout.swift b/Source/API/Page Format/PDFPageFormat+Layout.swift
index 9ec6e403e..bb83d4767 100644
--- a/Source/API/Page Format/PDFPageFormat+Layout.swift
+++ b/Source/API/Page Format/PDFPageFormat+Layout.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 11/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Page Format/PDFPageFormat+NameConstants.swift b/Source/API/Page Format/PDFPageFormat+NameConstants.swift
index 918207fea..085f1dac5 100644
--- a/Source/API/Page Format/PDFPageFormat+NameConstants.swift
+++ b/Source/API/Page Format/PDFPageFormat+NameConstants.swift
@@ -1,4 +1,4 @@
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Page Format/PDFPageFormat+SizeConstants.swift b/Source/API/Page Format/PDFPageFormat+SizeConstants.swift
index aeba67287..ed923e247 100644
--- a/Source/API/Page Format/PDFPageFormat+SizeConstants.swift
+++ b/Source/API/Page Format/PDFPageFormat+SizeConstants.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 11/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Page Format/PDFPageFormat.swift b/Source/API/Page Format/PDFPageFormat.swift
index 96aea0cb4..7af5cd619 100644
--- a/Source/API/Page Format/PDFPageFormat.swift
+++ b/Source/API/Page Format/PDFPageFormat.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 12/08/16.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Pagination/PDFPagination.swift b/Source/API/Pagination/PDFPagination.swift
index ce98328d7..864db49cb 100644
--- a/Source/API/Pagination/PDFPagination.swift
+++ b/Source/API/Pagination/PDFPagination.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 11/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Section/PDFSection.swift b/Source/API/Section/PDFSection.swift
index 4b7b21353..8f7d3b781 100644
--- a/Source/API/Section/PDFSection.swift
+++ b/Source/API/Section/PDFSection.swift
@@ -5,7 +5,7 @@
// Created by Marco Betschart on 05.05.18.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Section/PDFSectionColumn.swift b/Source/API/Section/PDFSectionColumn.swift
index f08ceb8ec..1fdffccf2 100644
--- a/Source/API/Section/PDFSectionColumn.swift
+++ b/Source/API/Section/PDFSectionColumn.swift
@@ -5,7 +5,7 @@
// Created by Marco Betschart on 05.05.18.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Table/Content/PDFTableContent.swift b/Source/API/Table/Content/PDFTableContent.swift
index afa9e378d..83a2948d4 100644
--- a/Source/API/Table/Content/PDFTableContent.swift
+++ b/Source/API/Table/Content/PDFTableContent.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 13/06/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Table/Content/UIImage+PDFTableContent.swift b/Source/API/Table/Content/UIImage+PDFTableContent.swift
index 358d0d06c..20a1095ef 100644
--- a/Source/API/Table/Content/UIImage+PDFTableContent.swift
+++ b/Source/API/Table/Content/UIImage+PDFTableContent.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 20.12.19.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Table/PDFTable.swift b/Source/API/Table/PDFTable.swift
index 56a19d676..3791d9c56 100644
--- a/Source/API/Table/PDFTable.swift
+++ b/Source/API/Table/PDFTable.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 13/06/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Table/Style/PDFTableCellStyle.swift b/Source/API/Table/Style/PDFTableCellStyle.swift
index ff351ad3b..016d73cf2 100644
--- a/Source/API/Table/Style/PDFTableCellStyle.swift
+++ b/Source/API/Table/Style/PDFTableCellStyle.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 11/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Table/Style/PDFTableStyle+Defaults.swift b/Source/API/Table/Style/PDFTableStyle+Defaults.swift
index 49b1c138b..facf8658a 100644
--- a/Source/API/Table/Style/PDFTableStyle+Defaults.swift
+++ b/Source/API/Table/Style/PDFTableStyle+Defaults.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 19/01/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Text/PDFAttributedText.swift b/Source/API/Text/PDFAttributedText.swift
index 213a00115..b0968b248 100644
--- a/Source/API/Text/PDFAttributedText.swift
+++ b/Source/API/Text/PDFAttributedText.swift
@@ -7,7 +7,7 @@
import Foundation
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Text/PDFSimpleText.swift b/Source/API/Text/PDFSimpleText.swift
index 17503b124..af4404ed4 100644
--- a/Source/API/Text/PDFSimpleText.swift
+++ b/Source/API/Text/PDFSimpleText.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 31/10/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Text/PDFTextStyle.swift b/Source/API/Text/PDFTextStyle.swift
index 2a36abbaa..24171e7d4 100644
--- a/Source/API/Text/PDFTextStyle.swift
+++ b/Source/API/Text/PDFTextStyle.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 28.05.19.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/API/Utils/CrossPlattformGraphics.swift b/Source/API/Utils/CrossPlattformGraphics.swift
index 632524b36..2890614b6 100644
--- a/Source/API/Utils/CrossPlattformGraphics.swift
+++ b/Source/API/Utils/CrossPlattformGraphics.swift
@@ -6,7 +6,7 @@
// Created by Philip Niedertscheider on 19.05.20.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
/// Cross-plattform type for `UIColor` and `NSColor`
diff --git a/Source/API/Utils/PDFRenderObject.swift b/Source/API/Utils/PDFRenderObject.swift
index 393eefff2..42d1346e5 100644
--- a/Source/API/Utils/PDFRenderObject.swift
+++ b/Source/API/Utils/PDFRenderObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 12/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/External/PDFExternalPageObject.swift b/Source/Internal/External/PDFExternalPageObject.swift
index 3075f07e7..2e1e898a0 100644
--- a/Source/Internal/External/PDFExternalPageObject.swift
+++ b/Source/Internal/External/PDFExternalPageObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 12.08.19.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Graphics/PDFContextGraphics.swift b/Source/Internal/Graphics/PDFContextGraphics.swift
index 2182674ac..21d31ed22 100644
--- a/Source/Internal/Graphics/PDFContextGraphics.swift
+++ b/Source/Internal/Graphics/PDFContextGraphics.swift
@@ -32,7 +32,7 @@ enum PDFContextGraphics {
}
#if os(macOS)
return Image(cgImage: cgImage, size: size)
- #elseif os(iOS)
+ #elseif os(iOS) || os(visionOS)
return Image(cgImage: cgImage)
#endif
}
diff --git a/Source/Internal/Graphics/PDFGraphics.swift b/Source/Internal/Graphics/PDFGraphics.swift
index 847c8c2ec..3a2269e31 100644
--- a/Source/Internal/Graphics/PDFGraphics.swift
+++ b/Source/Internal/Graphics/PDFGraphics.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 13/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
@@ -187,7 +187,7 @@ enum PDFGraphics {
let size = CGSize(width: floor(frame.width * resizeFactor),
height: floor(frame.height * resizeFactor))
- #if os(iOS)
+ #if os(iOS) || os(visionOS)
UIGraphicsBeginImageContext(size)
image.draw(in: CGRect(origin: .zero, size: size))
let finalImage = UIGraphicsGetImageFromCurrentImageContext()
@@ -215,7 +215,7 @@ enum PDFGraphics {
- Returns: Compressed image
*/
static func compress(image: Image, quality: CGFloat) -> Image {
- #if os(iOS)
+ #if os(iOS) || os(visionOS)
guard let data = image.jpegData(compressionQuality: quality) else {
return image
}
@@ -256,7 +256,7 @@ enum PDFGraphics {
let clipPath = BezierPath(roundedRect: CGRect(origin: .zero, size: size), byRoundingCorners: corners, cornerRadii: cornerRadii)
- #if os(iOS)
+ #if os(iOS) || os(visionOS)
UIGraphicsBeginImageContext(size)
#elseif os(macOS)
let finalImage = NSImage(size: size)
@@ -266,7 +266,7 @@ enum PDFGraphics {
clipPath.addClip()
image.draw(in: CGRect(origin: .zero, size: size))
- #if os(iOS)
+ #if os(iOS) || os(visionOS)
let finalImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return finalImage ?? image
@@ -291,7 +291,7 @@ enum PDFGraphics {
case let .dotted(foreColor, backColor):
let size = CGSize(width: 5, height: 5)
- #if os(iOS)
+ #if os(iOS) || os(visionOS)
UIGraphicsBeginImageContext(size)
#elseif os(macOS)
let image = NSImage(size: size)
@@ -307,7 +307,7 @@ enum PDFGraphics {
path = BezierPath(ovalIn: CGRect(x: 2.5, y: 2.5, width: 2.5, height: 2.5))
path.fill()
- #if os(iOS)
+ #if os(iOS) || os(visionOS)
let image = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
#elseif os(macOS)
diff --git a/Source/Internal/Graphics/PDFLineObject.swift b/Source/Internal/Graphics/PDFLineObject.swift
index e2c9c0aca..5694e044f 100644
--- a/Source/Internal/Graphics/PDFLineObject.swift
+++ b/Source/Internal/Graphics/PDFLineObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 06.12.17.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Graphics/PDFLineSeparatorObject.swift b/Source/Internal/Graphics/PDFLineSeparatorObject.swift
index 1df57f226..81c7432b5 100644
--- a/Source/Internal/Graphics/PDFLineSeparatorObject.swift
+++ b/Source/Internal/Graphics/PDFLineSeparatorObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 12/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Graphics/PDFRectangleObject.swift b/Source/Internal/Graphics/PDFRectangleObject.swift
index 7ebed30df..532d7b576 100644
--- a/Source/Internal/Graphics/PDFRectangleObject.swift
+++ b/Source/Internal/Graphics/PDFRectangleObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 06.12.17.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Graphics/UIColor+CloseToEqual.swift b/Source/Internal/Graphics/UIColor+CloseToEqual.swift
index cd51f276d..d7395aef3 100644
--- a/Source/Internal/Graphics/UIColor+CloseToEqual.swift
+++ b/Source/Internal/Graphics/UIColor+CloseToEqual.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 16/11/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Group/PDFGroupObject.swift b/Source/Internal/Group/PDFGroupObject.swift
index dfcaef983..498f21abb 100644
--- a/Source/Internal/Group/PDFGroupObject.swift
+++ b/Source/Internal/Group/PDFGroupObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 31.05.19.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
@@ -187,7 +187,7 @@ class PDFGroupObject: PDFRenderObject {
)
let cgImage: CGImage?
- #if os(iOS)
+ #if os(iOS) || os(visionOS)
cgImage = modifiedImage.cgImage
#elseif os(macOS)
cgImage = modifiedImage.cgImage(forProposedRect: nil, context: nil, hints: nil)
diff --git a/Source/Internal/Image/PDFImageObject.swift b/Source/Internal/Image/PDFImageObject.swift
index 7226bf376..3c9b212e9 100644
--- a/Source/Internal/Image/PDFImageObject.swift
+++ b/Source/Internal/Image/PDFImageObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 12/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
@@ -122,7 +122,7 @@ class PDFImageObject: PDFRenderObject {
cornerRadius: image.cornerRadius)
let cgImage: CGImage?
- #if os(iOS)
+ #if os(iOS) || os(visionOS)
cgImage = modifiedImage.cgImage
#elseif os(macOS)
cgImage = modifiedImage.cgImage(forProposedRect: nil, context: nil, hints: nil)
diff --git a/Source/Internal/Image/PDFImageRowObject.swift b/Source/Internal/Image/PDFImageRowObject.swift
index 3481bc77c..40818f5c3 100644
--- a/Source/Internal/Image/PDFImageRowObject.swift
+++ b/Source/Internal/Image/PDFImageRowObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 12/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Layout/PDFColumnLayoutState.swift b/Source/Internal/Layout/PDFColumnLayoutState.swift
index fc91b57f3..40878a8f5 100644
--- a/Source/Internal/Layout/PDFColumnLayoutState.swift
+++ b/Source/Internal/Layout/PDFColumnLayoutState.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 30.05.19.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Layout/PDFIndentationObject.swift b/Source/Internal/Layout/PDFIndentationObject.swift
index eea674eea..7c563ef50 100644
--- a/Source/Internal/Layout/PDFIndentationObject.swift
+++ b/Source/Internal/Layout/PDFIndentationObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 12/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Layout/PDFLayout.swift b/Source/Internal/Layout/PDFLayout.swift
index dbb9dc200..fe2568275 100644
--- a/Source/Internal/Layout/PDFLayout.swift
+++ b/Source/Internal/Layout/PDFLayout.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 31/10/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Layout/PDFLayoutHeights.swift b/Source/Internal/Layout/PDFLayoutHeights.swift
index adea90ef7..9a9b939f0 100644
--- a/Source/Internal/Layout/PDFLayoutHeights.swift
+++ b/Source/Internal/Layout/PDFLayoutHeights.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 30/10/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Layout/PDFLayoutIndentations.swift b/Source/Internal/Layout/PDFLayoutIndentations.swift
index 89f478738..01ecf169a 100644
--- a/Source/Internal/Layout/PDFLayoutIndentations.swift
+++ b/Source/Internal/Layout/PDFLayoutIndentations.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 30/10/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Layout/PDFMarginObject.swift b/Source/Internal/Layout/PDFMarginObject.swift
index fb45b0d9b..71162c1b7 100644
--- a/Source/Internal/Layout/PDFMarginObject.swift
+++ b/Source/Internal/Layout/PDFMarginObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 31.05.19.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Layout/PDFOffsetObject.swift b/Source/Internal/Layout/PDFOffsetObject.swift
index 5673985ed..8fff8b68f 100644
--- a/Source/Internal/Layout/PDFOffsetObject.swift
+++ b/Source/Internal/Layout/PDFOffsetObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 12/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Layout/PDFPageBreakObject.swift b/Source/Internal/Layout/PDFPageBreakObject.swift
index 1ecd24f15..8885bcabf 100644
--- a/Source/Internal/Layout/PDFPageBreakObject.swift
+++ b/Source/Internal/Layout/PDFPageBreakObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 12/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Layout/PDFSpaceObject.swift b/Source/Internal/Layout/PDFSpaceObject.swift
index e6e2852e1..711667150 100644
--- a/Source/Internal/Layout/PDFSpaceObject.swift
+++ b/Source/Internal/Layout/PDFSpaceObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 12/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Math/CGPoint+Math.swift b/Source/Internal/Math/CGPoint+Math.swift
index 055fc7659..e56d84eb6 100644
--- a/Source/Internal/Math/CGPoint+Math.swift
+++ b/Source/Internal/Math/CGPoint+Math.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 04/11/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Math/CGPoint+Null.swift b/Source/Internal/Math/CGPoint+Null.swift
index 77f3d8e88..a69e45df2 100644
--- a/Source/Internal/Math/CGPoint+Null.swift
+++ b/Source/Internal/Math/CGPoint+Null.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 06.01.20.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/PDFGenerator+Debug.swift b/Source/Internal/PDFGenerator+Debug.swift
index 8c59f5727..888a4bb96 100644
--- a/Source/Internal/PDFGenerator+Debug.swift
+++ b/Source/Internal/PDFGenerator+Debug.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 24/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/PDFGenerator+Layout.swift b/Source/Internal/PDFGenerator+Layout.swift
index 925daa16e..5054967b1 100644
--- a/Source/Internal/PDFGenerator+Layout.swift
+++ b/Source/Internal/PDFGenerator+Layout.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 13/06/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Section/PDFColumnWrapSectionObject.swift b/Source/Internal/Section/PDFColumnWrapSectionObject.swift
index df6bdddae..a05a57b76 100644
--- a/Source/Internal/Section/PDFColumnWrapSectionObject.swift
+++ b/Source/Internal/Section/PDFColumnWrapSectionObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 28.05.19.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Section/PDFSectionObject.swift b/Source/Internal/Section/PDFSectionObject.swift
index 9ef56d472..7a842b95b 100644
--- a/Source/Internal/Section/PDFSectionObject.swift
+++ b/Source/Internal/Section/PDFSectionObject.swift
@@ -5,7 +5,7 @@
// Created by Marco Betschart on 05.05.18.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Table/PDFTableObject.swift b/Source/Internal/Table/PDFTableObject.swift
index 4d631d7f9..5389e41fd 100644
--- a/Source/Internal/Table/PDFTableObject.swift
+++ b/Source/Internal/Table/PDFTableObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 12/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Table/PDFTableValidator.swift b/Source/Internal/Table/PDFTableValidator.swift
index 50eb0e43c..4b8f7bf15 100644
--- a/Source/Internal/Table/PDFTableValidator.swift
+++ b/Source/Internal/Table/PDFTableValidator.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 11/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Text/PDFAttributedTextObject.swift b/Source/Internal/Text/PDFAttributedTextObject.swift
index fbedf147b..580c1cd81 100644
--- a/Source/Internal/Text/PDFAttributedTextObject.swift
+++ b/Source/Internal/Text/PDFAttributedTextObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 12/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Text/PDFFontObject.swift b/Source/Internal/Text/PDFFontObject.swift
index 845d18581..680d0b87c 100644
--- a/Source/Internal/Text/PDFFontObject.swift
+++ b/Source/Internal/Text/PDFFontObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 12/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Text/PDFTextColorObject.swift b/Source/Internal/Text/PDFTextColorObject.swift
index b5012d307..8c2aebd3b 100644
--- a/Source/Internal/Text/PDFTextColorObject.swift
+++ b/Source/Internal/Text/PDFTextColorObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 12/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Utils/PDFCalculations.swift b/Source/Internal/Utils/PDFCalculations.swift
index 70dfdebb1..8a09d1a3b 100644
--- a/Source/Internal/Utils/PDFCalculations.swift
+++ b/Source/Internal/Utils/PDFCalculations.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 24/08/2017.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Source/Internal/Utils/PDFSlicedObject.swift b/Source/Internal/Utils/PDFSlicedObject.swift
index 4cf0c0c45..cb21222d7 100644
--- a/Source/Internal/Utils/PDFSlicedObject.swift
+++ b/Source/Internal/Utils/PDFSlicedObject.swift
@@ -5,7 +5,7 @@
// Created by Philip Niedertscheider on 06.01.20.
//
-#if os(iOS)
+#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
diff --git a/Tests/TPPDFTests/Internal/Table/PDFTableObjectSpec.swift b/Tests/TPPDFTests/Internal/Table/PDFTableObjectSpec.swift
index 9261d087b..d7905e9ed 100644
--- a/Tests/TPPDFTests/Internal/Table/PDFTableObjectSpec.swift
+++ b/Tests/TPPDFTests/Internal/Table/PDFTableObjectSpec.swift
@@ -5,7 +5,7 @@ import Quick
@testable import TPPDF
import XCTest
-#if os(iOS)
+#if os(iOS) || os(visionOS)
class PDFTableObjectSpec: XCTestCase {
/// Preconditions:
/// - Multiple pages
From a719e9d834e0cc9e41e133ab1b1add4527c84858 Mon Sep 17 00:00:00 2001
From: Paul Schmiedmayer
Date: Fri, 28 Jun 2024 20:59:59 -0700
Subject: [PATCH 2/4] Update GitHub Action
---
.github/workflows/tests.yml | 42 +++++++++++--------
README.md | 8 +++-
Source/API/PDFGenerator+Generation.swift | 2 +-
.../API/Pagination/PDFPaginationStyle.swift | 3 +-
4 files changed, 34 insertions(+), 21 deletions(-)
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 051e9d741..7718a095b 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -12,22 +12,27 @@ concurrency:
cancel-in-progress: true
jobs:
- ios-unit-tests:
- name: iOS Unit Tests
+ unit-tests:
+ name: Unit Tests
runs-on: macos-14
timeout-minutes: 30
strategy:
matrix:
build: [
- { sdk: 'iphonesimulator', destination: 'platform=iOS Simulator,OS=17.5,name=iPhone 15 Pro' },
- { sdk: 'xros', destination: 'platform=visionOS Simulator,OS=1.2,name=Apple Vision Pro' }
+ { sdk: 'iphonesimulator', destination: 'platform=iOS Simulator,OS=17.5,name=iPhone 15 Pro', action: 'test' },
+ { sdk: 'xros', destination: 'platform=visionOS Simulator,OS=1.2,name=Apple Vision Pro', action: 'build' }
]
steps:
- - # Checkout the repository
+ - name: Checkout the repository
uses: actions/checkout@v4
-
- - # Run Tests
- name: Run Tests iOS
+ - uses: maxim-lobanov/setup-xcode@v1
+ with:
+ xcode-version: latest-stable
+ - name: Check environment
+ run: |
+ xcodebuild -version
+ swift --version
+ - name: Run Tests
run: |
set -o pipefail && \
env NSUnbufferedIO=YES \
@@ -36,20 +41,19 @@ jobs:
-sdk "${{ matrix.build.sdk }}" \
-destination "${{ matrix.build.destination }}" \
-configuration Debug \
- -enableCodeCoverage YES \
+ ${{ matrix.build.action == 'test' && '-enableCodeCoverage YES' || '' }} \
-derivedDataPath /tmp/DerivedData \
-resultBundlePath test_output \
CODE_SIGNING_ALLOWED="NO" \
- test 2>&1 | tee test.log | xcbeautify
-
+ ${{ matrix.build.action }} 2>&1 | tee test.log | xcbeautify
- name: Upload test log file on error
uses: actions/upload-artifact@v4
if: failure()
with:
name: test.log
path: test.log
-
- name: Generate code coverage reports
+ if: matrix.build.action == 'test'
run: |
PROFDATA_PATH=$(find /tmp/DerivedData -name "*.profdata")
echo "Detected profdata at path: $PROFDATA_PATH"
@@ -67,13 +71,17 @@ jobs:
runs-on: macos-14
timeout-minutes: 30
steps:
- - # Checkout the repository
+ - name: Checkout the repository
uses: actions/checkout@v4
-
- - # Run Tests
- name: Run tests
+ - uses: maxim-lobanov/setup-xcode@v1
+ with:
+ xcode-version: latest-stable
+ - name: Check environment
+ run: |
+ xcodebuild -version
+ swift --version
+ - name: Run tests
run: swift test --parallel --enable-code-coverage
-
- name: Generate code coverage reports
run: |
xcrun llvm-cov export \
diff --git a/README.md b/README.md
index 649d33c33..aecd8ef52 100644
--- a/README.md
+++ b/README.md
@@ -9,8 +9,12 @@
diff --git a/Source/API/PDFGenerator+Generation.swift b/Source/API/PDFGenerator+Generation.swift
index 2b70e7025..74d2a5850 100644
--- a/Source/API/PDFGenerator+Generation.swift
+++ b/Source/API/PDFGenerator+Generation.swift
@@ -452,7 +452,7 @@ public extension PDFGenerator {
elements.append((styleIndex, textObj))
}
}
- let list = PDFList(indentations: styles.enumerated().map { (pre: CGFloat($0.offset + 1) * 10, past: 10) })
+ let list = PDFList(indentations: styles.indices.map { (pre: CGFloat($0 + 1) * 10, past: 10) })
var stack = Stack()
for (index, element) in elements {
let item = PDFListItem(symbol: symbol, content: element.simpleText?.text)
diff --git a/Source/API/Pagination/PDFPaginationStyle.swift b/Source/API/Pagination/PDFPaginationStyle.swift
index 4605ff095..8ab0c2d83 100644
--- a/Source/API/Pagination/PDFPaginationStyle.swift
+++ b/Source/API/Pagination/PDFPaginationStyle.swift
@@ -10,7 +10,8 @@ import Foundation
/**
* Use predefined pagination styles or create a custom one, using `.CustomNumberFormat` or `.CustomClosure`.
*
- * Enums using a template String as parameter will replace the first instance of `%@` with the index and the second one with the total amount of pages.
+ * Enums using a template String as parameter will replace the first instance of `%@` with the index
+ * and the second one with the total amount of pages.
*/
public enum PDFPaginationStyle {
/**
From 8ccd9c1a05109efd0ac453de1a94ba806d4d958e Mon Sep 17 00:00:00 2001
From: Paul Schmiedmayer
Date: Sat, 6 Jul 2024 13:20:52 -0700
Subject: [PATCH 3/4] Update GitHub Action Name
---
.github/workflows/tests.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 7718a095b..bc894dcd5 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -13,7 +13,7 @@ concurrency:
jobs:
unit-tests:
- name: Unit Tests
+ name: Unit Tests (${{ matrix.build.sdk }})
runs-on: macos-14
timeout-minutes: 30
strategy:
From 36e86158ccf9826f3734b772092296d79efd0874 Mon Sep 17 00:00:00 2001
From: Paul Schmiedmayer
Date: Mon, 8 Jul 2024 09:43:21 -0700
Subject: [PATCH 4/4] Update GitHub Actions
---
.github/workflows/danger.yml | 2 +-
.github/workflows/tests.yml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml
index b4f23fbbd..06c63576c 100644
--- a/.github/workflows/danger.yml
+++ b/.github/workflows/danger.yml
@@ -17,4 +17,4 @@ jobs:
with:
args: --failOnErrors --no-publish-check
env:
- GITHUB_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
+ GITHUB_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN || secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index bc894dcd5..caaea16d6 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -67,7 +67,7 @@ jobs:
--format="lcov" > integration-tests.coverage.lcov
macos-unit-tests:
- name: macOS Unit Tests
+ name: Unit Tests (macos)
runs-on: macos-14
timeout-minutes: 30
steps: