Skip to content

Commit 89d20b5

Browse files
committed
WIP
1 parent 1e2afa9 commit 89d20b5

File tree

98 files changed

+1082
-735
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1082
-735
lines changed

.github/workflows/documentation.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ jobs:
2828
2929
- name: Generate Documentation with Jazzy
3030
run: |
31-
SDK_PATH=`xcrun --sdk iphonesimulator --show-sdk-path`
32-
SDK_VERSION=`xcrun --sdk iphonesimulator --show-sdk-version`
33-
bundle exec jazzy \
34-
--build-tool-arguments "--sdk,${SDK_PATH},-Xswiftc,-sdk,-Xswiftc,$SDK_PATH,-Xswiftc,-target,-Xswiftc,arm64-apple-ios${SDK_VERSION}-simulator"
31+
make build-docs
3532
3633
- name: Fix Invalid URLs
3734
run: |

.github/workflows/release.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@ jobs:
1818
- name: Checkout Repository
1919
uses: actions/checkout@v5
2020

21-
- uses: maxim-lobanov/setup-xcode@v1
22-
with:
23-
xcode-version: latest-stable
24-
2521
- name: Install Dependencies
26-
run: brew install tree
22+
run: make install-ci
2723

2824
- name: Create XCFramework
29-
run: ./scripts/create-xcframework.sh
25+
run: make build-xcframework
3026

3127
- name: Create GitHub Release
3228
uses: marvinpinto/action-automatic-releases@latest

.github/workflows/tests.yml

Lines changed: 25 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -13,93 +13,46 @@ concurrency:
1313

1414
jobs:
1515
unit-tests:
16-
name: Unit Tests (${{ matrix.build.sdk }})
16+
name: Unit Tests (${{ matrix.build.name }})
1717
runs-on: ${{ matrix.build.runs-on }}
1818
timeout-minutes: 30
1919
strategy:
2020
matrix:
2121
build:
22-
- sdk: "iphonesimulator"
23-
destination: "platform=iOS Simulator,OS=18.1,name=iPhone 16 Pro"
24-
action: "test"
22+
- name: iOS
23+
destination: "platform=iOS Simulator,OS=26.2,name=iPhone 17 Pro"
24+
action: "ci-test-ios"
2525
runs-on: "macos-15"
26-
- sdk: "xros"
26+
- name: macOS
27+
destination: "platform=macOS,arch=arm64"
28+
action: "ci-test-macos"
29+
runs-on: "macos-15"
30+
- name: Mac Catalyst
31+
destination: "platform=macOS Catalyst,OS=16.0,name=Mac"
32+
action: "ci-test-maccatalyst"
33+
runs-on: "macos-15"
34+
- name: tvOS
35+
destination: "platform=tvOS Simulator,OS=17.2,name=Apple TV 4K (3rd generation)"
36+
action: "ci-test-tvos"
37+
runs-on: "macos-15"
38+
- name: watchOS
39+
destination: "platform=watchOS Simulator,OS=10.2,name=Apple Watch Series 8 - 45mm"
40+
action: "ci-test-watchos"
41+
runs-on: "macos-15"
42+
- name: visionOS
2743
destination: "platform=visionOS Simulator,OS=2.1,name=Apple Vision Pro"
28-
action: "build"
44+
action: "ci-test-visionos"
2945
runs-on: "macos-15"
3046
steps:
3147
- name: Checkout the repository
3248
uses: actions/checkout@v5
33-
- uses: maxim-lobanov/setup-xcode@v1
34-
with:
35-
xcode-version: latest-stable
36-
- name: Check environment
37-
run: |
38-
set -ex
39-
xcodebuild -version
40-
swift --version
41-
xcrun simctl list
42-
- name: Enable development dependencies
43-
run: |
44-
sed -i.bak "s/\/\/dev//g" Package.swift
49+
4550
- name: Run Tests
46-
run: |
47-
set -o pipefail && \
48-
env NSUnbufferedIO=YES \
49-
xcodebuild -workspace . \
50-
-scheme "TPPDF" \
51-
-sdk "${{ matrix.build.sdk }}" \
52-
-destination "${{ matrix.build.destination }}" \
53-
-configuration Debug \
54-
${{ matrix.build.action == 'test' && '-enableCodeCoverage YES' || '' }} \
55-
-derivedDataPath /tmp/DerivedData \
56-
-resultBundlePath test_output \
57-
CODE_SIGNING_ALLOWED="NO" \
58-
${{ matrix.build.action }} 2>&1 | tee test.log | xcbeautify
51+
run: make ${{ matrix.build.action }} DESTINATION="${{ matrix.build.destination }}"
52+
5953
- name: Upload test log file on error
6054
uses: actions/upload-artifact@v4
6155
if: failure()
6256
with:
6357
name: test.log
6458
path: test.log
65-
- name: Generate code coverage reports
66-
if: matrix.build.action == 'test'
67-
run: |
68-
PROFDATA_PATH=$(find /tmp/DerivedData -name "*.profdata")
69-
echo "Detected profdata at path: $PROFDATA_PATH"
70-
xcrun llvm-cov export \
71-
/tmp/DerivedData/Build/Products/Debug-iphonesimulator/TPPDFTests.xctest/TPPDFTests \
72-
--instr-profile $PROFDATA_PATH \
73-
--format="lcov" > unit-tests.coverage.lcov
74-
xcrun llvm-cov export \
75-
/tmp/DerivedData/Build/Products/Debug-iphonesimulator/TPPDFIntegrationTests.xctest/TPPDFIntegrationTests \
76-
--instr-profile $PROFDATA_PATH \
77-
--format="lcov" > integration-tests.coverage.lcov
78-
79-
macos-unit-tests:
80-
name: Unit Tests (macos)
81-
runs-on: macos-15
82-
timeout-minutes: 30
83-
steps:
84-
- name: Checkout the repository
85-
uses: actions/checkout@v5
86-
- uses: maxim-lobanov/setup-xcode@v1
87-
with:
88-
xcode-version: latest-stable
89-
- name: Check environment
90-
run: |
91-
set -ex
92-
xcodebuild -version
93-
swift --version
94-
xcrun simctl list
95-
- name: Enable development dependencies
96-
run: |
97-
sed -i.bak "s/\/\/dev//g" Package.swift
98-
- name: Run tests
99-
run: swift test --parallel --enable-code-coverage
100-
- name: Generate code coverage reports
101-
run: |
102-
xcrun llvm-cov export \
103-
.build/debug/TPPDFPackageTests.xctest/Contents/MacOS/TPPDFPackageTests \
104-
--instr-profile .build/debug/codecov/default.profdata \
105-
--format="lcov" > coverage.lcov

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,6 @@ vendor
6868
*.lcov
6969
test_output
7070
test_output*
71+
72+
raw-build-*.log
73+
raw-test-*.log

Brewfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
brew "tree"

Example macOS/Example/UI/PDFView+SwiftUI.swift

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,52 +9,50 @@
99
import PDFKit
1010
import SwiftUI
1111

12-
#if os(macOS)
13-
import AppKit
14-
15-
struct PDFKitRepresentedView: NSViewRepresentable {
16-
var url: URL?
17-
18-
func makeNSView(context _: NSViewRepresentableContext<PDFKitRepresentedView>) -> PDFKitRepresentedView.NSViewType {
19-
let pdfView = PDFView()
20-
if let url = url {
21-
pdfView.document = PDFDocument(url: url)
22-
} else {
23-
pdfView.document = nil
24-
}
25-
return pdfView
26-
}
12+
#if os(iOS)
13+
import UIKit
2714

28-
func updateNSView(_ nsView: NSView, context _: NSViewRepresentableContext<PDFKitRepresentedView>) {
29-
guard let pdfView = nsView as? PDFView else {
30-
return
31-
}
32-
if let url = url {
33-
pdfView.document = PDFDocument(url: url)
34-
} else {
35-
pdfView.document = nil
36-
}
37-
}
15+
struct PDFKitRepresentedView: UIViewRepresentable {
16+
let url: URL
17+
18+
init(_ url: URL) {
19+
self.url = url
3820
}
3921

40-
#elseif os(iOS)
41-
import UIKit
22+
func makeUIView(context _: UIViewRepresentableContext<PDFKitRepresentedView>) -> PDFKitRepresentedView.UIViewType {
23+
// Create a `PDFView` and set its `PDFDocument`.
24+
let pdfView = PDFView()
25+
pdfView.document = PDFDocument(url: url)
26+
return pdfView
27+
}
4228

43-
struct PDFKitRepresentedView: UIViewRepresentable {
44-
let url: URL
29+
func updateUIView(_: UIView, context _: UIViewRepresentableContext<PDFKitRepresentedView>) {}
30+
}
31+
#else
32+
import AppKit
4533

46-
init(_ url: URL) {
47-
self.url = url
48-
}
34+
struct PDFKitRepresentedView: NSViewRepresentable {
35+
var url: URL?
4936

50-
func makeUIView(context _: UIViewRepresentableContext<PDFKitRepresentedView>) -> PDFKitRepresentedView.UIViewType {
51-
// Create a `PDFView` and set its `PDFDocument`.
52-
let pdfView = PDFView()
37+
func makeNSView(context _: NSViewRepresentableContext<PDFKitRepresentedView>) -> PDFKitRepresentedView.NSViewType {
38+
let pdfView = PDFView()
39+
if let url = url {
5340
pdfView.document = PDFDocument(url: url)
54-
return pdfView
41+
} else {
42+
pdfView.document = nil
5543
}
56-
57-
func updateUIView(_: UIView, context _: UIViewRepresentableContext<PDFKitRepresentedView>) {}
44+
return pdfView
5845
}
5946

47+
func updateNSView(_ nsView: NSView, context _: NSViewRepresentableContext<PDFKitRepresentedView>) {
48+
guard let pdfView = nsView as? PDFView else {
49+
return
50+
}
51+
if let url = url {
52+
pdfView.document = PDFDocument(url: url)
53+
} else {
54+
pdfView.document = nil
55+
}
56+
}
57+
}
6058
#endif

0 commit comments

Comments
 (0)