Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add visionOS Support #384

Merged
merged 5 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/danger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
50 changes: 32 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,48 @@ concurrency:
cancel-in-progress: true

jobs:
ios-unit-tests:
name: iOS Unit Tests
unit-tests:
name: Unit Tests (${{ matrix.build.sdk }})
runs-on: macos-14
timeout-minutes: 30
strategy:
matrix:
build: [
{ 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 \
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 \
${{ 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"
Expand All @@ -57,17 +67,21 @@ 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:
- # 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 \
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
## Build generated
build/
DerivedData
test.log

## Various settings
*.pbxuser
Expand Down
10 changes: 10 additions & 0 deletions Example iOS-SwiftPM/Example_iOS-SPM.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
</p>

<div align="center">
<img src="https://img.shields.io/badge/language-Swift-orange.svg?style=flat-square" alt="Swift"/>
<img src="https://img.shields.io/badge/platforms-iOS|macOS-lightgrey.svg?style=flat-square" alt="iOS|macOS"/>
<a href="https://swiftpackageindex.com/techprimate/TPPDF">
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Ftechprimate%2FTPPDF%2Fbadge%3Ftype%3Dswift-versions" alt="Supported Swift Versions">
</a>
<a href="https://swiftpackageindex.com/techprimate/TPPDF">
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Ftechprimate%2FTPPDF%2Fbadge%3Ftype%3Dplatforms" alt="Supported Platforms">
</a>
<img src="https://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat-square" alt="License"/>
</div>

Expand Down
54 changes: 33 additions & 21 deletions Shared iOS/Assets/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="CZA-F0-5Pi">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="CZA-F0-5Pi">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Example" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Example_iOS_Carthage" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="cnM-58-c1z"/>
<viewControllerLayoutGuide type="bottom" id="6df-A8-lCn"/>
Expand All @@ -19,33 +19,37 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dhg-dm-cGT">
<rect key="frame" x="0.0" y="88" width="414" height="774"/>
<wkWebView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="aWi-cf-GIW">
<rect key="frame" x="0.0" y="92" width="414" height="770"/>
<color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</webView>
<wkWebViewConfiguration key="configuration">
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
<wkPreferences key="preferences"/>
</wkWebViewConfiguration>
</wkWebView>
<progressView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="ECf-M0-eMp">
<rect key="frame" x="132" y="443" width="150" height="10"/>
<rect key="frame" x="16" y="472" width="382" height="10"/>
<constraints>
<constraint firstAttribute="height" constant="10" id="Npy-uE-RHq"/>
</constraints>
<color key="progressTintColor" systemColor="systemGreenColor" red="0.20392156859999999" green="0.78039215689999997" blue="0.34901960780000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="progressTintColor" systemColor="systemGreenColor"/>
</progressView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="dhg-dm-cGT" firstAttribute="top" secondItem="cnM-58-c1z" secondAttribute="bottom" id="G7f-Nc-ygc"/>
<constraint firstItem="6df-A8-lCn" firstAttribute="top" secondItem="dhg-dm-cGT" secondAttribute="bottom" id="OBA-EM-IEV"/>
<constraint firstItem="dhg-dm-cGT" firstAttribute="leading" secondItem="y9Q-UB-G5G" secondAttribute="leading" id="ZFp-iK-dzX"/>
<constraint firstItem="ECf-M0-eMp" firstAttribute="centerX" secondItem="y9Q-UB-G5G" secondAttribute="centerX" id="ZuF-rx-ajr"/>
<constraint firstItem="ECf-M0-eMp" firstAttribute="centerY" secondItem="y9Q-UB-G5G" secondAttribute="centerY" id="bMd-uV-Qnf"/>
<constraint firstAttribute="trailing" secondItem="dhg-dm-cGT" secondAttribute="trailing" id="ddb-h6-0Kq"/>
<constraint firstItem="ECf-M0-eMp" firstAttribute="leading" secondItem="y9Q-UB-G5G" secondAttribute="leading" constant="132" id="jie-x0-42q"/>
<constraint firstAttribute="trailing" secondItem="aWi-cf-GIW" secondAttribute="trailing" id="Luq-wu-p44"/>
<constraint firstItem="ECf-M0-eMp" firstAttribute="trailing" secondItem="aWi-cf-GIW" secondAttribute="trailing" constant="-16" id="PrP-JI-vxh"/>
<constraint firstItem="aWi-cf-GIW" firstAttribute="top" secondItem="cnM-58-c1z" secondAttribute="bottom" id="Tp6-kI-cXY"/>
<constraint firstItem="ECf-M0-eMp" firstAttribute="leading" secondItem="aWi-cf-GIW" secondAttribute="leading" constant="16" id="Uqd-tc-BqV"/>
<constraint firstItem="6df-A8-lCn" firstAttribute="top" secondItem="aWi-cf-GIW" secondAttribute="bottom" id="cPb-lT-smd"/>
<constraint firstItem="ECf-M0-eMp" firstAttribute="centerY" secondItem="aWi-cf-GIW" secondAttribute="centerY" id="sDV-bI-lUx"/>
<constraint firstItem="aWi-cf-GIW" firstAttribute="leading" secondItem="y9Q-UB-G5G" secondAttribute="leading" id="xDT-cD-Z1K"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="AOi-yM-ZqB"/>
<connections>
<outlet property="progressView" destination="ECf-M0-eMp" id="45h-Jk-28n"/>
<outlet property="webView" destination="dhg-dm-cGT" id="l9E-a3-BRe"/>
<outlet property="webView" destination="aWi-cf-GIW" id="uMO-Su-otG"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
Expand All @@ -55,11 +59,11 @@
<!--Examples-->
<scene sceneID="e2C-tU-P2m">
<objects>
<tableViewController id="OQp-47-Jlk" customClass="ExamplesListViewController" customModule="Example" customModuleProvider="target" sceneMemberID="viewController">
<tableViewController id="OQp-47-Jlk" customClass="ExamplesListViewController" customModule="Example_iOS_Carthage" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="jy2-SO-vwO">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="example-cell" textLabel="jGR-ZO-nLT" style="IBUITableViewCellStyleDefault" id="8S8-SC-SS5">
<rect key="frame" x="0.0" y="55.5" width="414" height="43.5"/>
Expand Down Expand Up @@ -99,7 +103,7 @@
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="CZA-F0-5Pi" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="zct-xR-tbq">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<rect key="frame" x="0.0" y="48" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
Expand All @@ -112,4 +116,12 @@
<point key="canvasLocation" x="-878.26086956521749" y="30.803571428571427"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemGreenColor">
<color red="0.20392156862745098" green="0.7803921568627451" blue="0.34901960784313724" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
5 changes: 3 additions & 2 deletions Shared iOS/UI/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Shared/Examples/DocumentSettingsExampleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Shared/Examples/GroupExampleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Shared/Examples/ImageExampleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Shared/Examples/LineSeparatorExampleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Shared/Examples/MetadataExampleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Shared/Examples/MultiSectionExampleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import TPPDF
#if os(iOS)
#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
Expand Down
2 changes: 1 addition & 1 deletion Shared/Examples/ObjectAttributesExampleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Shared/Examples/PaginationExampleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Shared/Examples/TableExampleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Shared/Examples/TableOfContentsExampleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Shared/Examples/TextExampleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Shared/Examples/TextStylesExampleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Source/API/Document/PDFDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Source/API/Graphics/PDFBezierPath+Copying.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading