diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e669108e..f93c5a99 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,9 +22,9 @@ jobs: [ { sdk: "iphonesimulator", - destination: "platform=iOS Simulator,OS=18.0,name=iPhone 16 Pro", + destination: "platform=iOS Simulator,OS=18.1,name=iPhone 16 Pro", action: "test", - runs-on: "macos-14", + runs-on: "macos-15", }, { sdk: "xros", diff --git a/.swiftlint.yml b/.swiftlint.yml index a58c8f60..b7f06be5 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -3,6 +3,7 @@ disabled_rules: - large_tuple - todo - inclusive_language + - trailing_comma excluded: - Carthage - Pods diff --git a/Dangerfile.swift b/Dangerfile.swift index baf17580..c2c29b98 100644 --- a/Dangerfile.swift +++ b/Dangerfile.swift @@ -5,15 +5,7 @@ let danger = Danger() // Changelog entries are required for changes to library files. let allSourceFiles = danger.git.modifiedFiles + danger.git.createdFiles -let noChangelogEntry = !allSourceFiles.contains("CHANGELOG.md") let sourceChanges = allSourceFiles.contains { $0.hasPrefix("Source") } -let isNotTrivial = !danger.github.pullRequest.title.contains("#trivial") -if isNotTrivial && noChangelogEntry && sourceChanges { - danger.warn(""" - Any changes to library code should be reflected in the Changelog. - Please consider adding a note there. - """) -} // Make it more obvious that a PR is a work in progress and shouldn't be merged yet if danger.github.pullRequest.title.contains("WIP") || danger.github.pullRequest.title.contains("Draft") { diff --git a/Example macOS/Example/UI/DetailView.swift b/Example macOS/Example/UI/DetailView.swift index 62233c64..2e069646 100644 --- a/Example macOS/Example/UI/DetailView.swift +++ b/Example macOS/Example/UI/DetailView.swift @@ -18,14 +18,22 @@ struct DetailView: View { @State var observer: NSObjectProtocol! = nil @State var progressValue: Double = 0.5 + @State var debug = false + var body: some View { VStack(alignment: .leading, spacing: 0) { HStack { Text("\(example.name)") .font(.headline) + Toggle(isOn: $debug) { + Text("Debug Mode") + } + .onChange(of: debug) { debug in + self.generatePDF(force: true, debug: debug) + } Spacer() Button(action: { - self.generatePDF(force: true) + self.generatePDF(force: true, debug: debug) }, label: { Text("Refresh") }) @@ -36,12 +44,12 @@ struct DetailView: View { PDFKitRepresentedView(url: url) .onAppear { - self.generatePDF(force: false) + self.generatePDF(force: false, debug: debug) } } } - func generatePDF(force: Bool) { + func generatePDF(force: Bool, debug: Bool) { if url != nil && !force { return } @@ -51,7 +59,7 @@ struct DetailView: View { } else { generator = PDFMultiDocumentGenerator(documents: docs) } - generator.debug = true + generator.debug = debug observer = generator.progress.observe(\.completedUnitCount) { progress, _ in self.progressValue = progress.fractionCompleted @@ -59,7 +67,7 @@ struct DetailView: View { DispatchQueue.global(qos: .background).async { do { - let url = try self.generator.generateURL(filename: "output.pdf") + let url = try self.generator.generateURL(filename: "output-\(UUID().uuidString).pdf") DispatchQueue.main.async { self.url = url } diff --git a/Example macOS/Example_macOS-SPM.xcodeproj/project.pbxproj b/Example macOS/Example_macOS-SPM.xcodeproj/project.pbxproj index 25baea87..8c186287 100644 --- a/Example macOS/Example_macOS-SPM.xcodeproj/project.pbxproj +++ b/Example macOS/Example_macOS-SPM.xcodeproj/project.pbxproj @@ -527,7 +527,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MACOSX_DEPLOYMENT_TARGET = 10.15; + MACOSX_DEPLOYMENT_TARGET = 11; PRODUCT_BUNDLE_IDENTIFIER = com.techprimate.TPPDF.Example; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -554,7 +554,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MACOSX_DEPLOYMENT_TARGET = 10.15; + MACOSX_DEPLOYMENT_TARGET = 11; PRODUCT_BUNDLE_IDENTIFIER = com.techprimate.TPPDF.Example; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Package.swift b/Package.swift index cf0069b3..f1f1eccb 100644 --- a/Package.swift +++ b/Package.swift @@ -7,7 +7,7 @@ let package = Package( platforms: [ .iOS(.v9), .macOS(.v10_14), - .visionOS(.v1) + .visionOS(.v1), ], products: [ .library(name: "TPPDF", targets: ["TPPDF"]), diff --git a/Source/API/Layout/PDFContainer.swift b/Source/API/Layout/PDFContainer.swift index 15591b19..1b083d55 100644 --- a/Source/API/Layout/PDFContainer.swift +++ b/Source/API/Layout/PDFContainer.swift @@ -96,7 +96,7 @@ public enum PDFContainer: CaseIterable { [ .headerLeft, .headerCenter, .headerRight, .contentLeft, .contentCenter, .contentRight, - .footerLeft, .footerCenter, .footerRight + .footerLeft, .footerCenter, .footerRight, ] } } diff --git a/Source/API/Metadata/PDFInfo.swift b/Source/API/Metadata/PDFInfo.swift index 5f6fcf6b..184216a9 100644 --- a/Source/API/Metadata/PDFInfo.swift +++ b/Source/API/Metadata/PDFInfo.swift @@ -98,7 +98,7 @@ public class PDFInfo { kCGPDFContextSubject as String: subject, kCGPDFContextKeywords as String: keywords, kCGPDFContextAllowsPrinting as String: allowsPrinting, - kCGPDFContextAllowsCopying as String: allowsCopying + kCGPDFContextAllowsCopying as String: allowsCopying, ] var creator = Bundle.main.infoDictionary?["CFBundleName"] as? String ?? "TPPDF" diff --git a/Source/API/PDFGenerator+Generation.swift b/Source/API/PDFGenerator+Generation.swift index 74d2a585..4e4753ec 100644 --- a/Source/API/PDFGenerator+Generation.swift +++ b/Source/API/PDFGenerator+Generation.swift @@ -329,7 +329,7 @@ public extension PDFGenerator { layout.margin.top + layout.heights.maxHeaderHeight(), layout.margin.top + layout.heights.maxHeaderHeight() + document.layout.space.header, document.layout.height - layout.margin.bottom - layout.heights.maxFooterHeight(), - document.layout.height - layout.margin.bottom - layout.heights.maxFooterHeight() - document.layout.space.footer + document.layout.height - layout.margin.bottom - layout.heights.maxFooterHeight() - document.layout.space.footer, ] var lines: [PDFLineObject] = [] diff --git a/Source/API/Utils/CrossPlattformGraphics.swift b/Source/API/Utils/CrossPlattformGraphics.swift index 2890614b..2cd219f3 100644 --- a/Source/API/Utils/CrossPlattformGraphics.swift +++ b/Source/API/Utils/CrossPlattformGraphics.swift @@ -66,7 +66,7 @@ } } - extension NSEdgeInsets: Equatable { + extension NSEdgeInsets: @retroactive Equatable { public static func == (lhs: NSEdgeInsets, rhs: NSEdgeInsets) -> Bool { lhs.top == rhs.top && lhs.left == rhs.left && lhs.bottom == rhs.bottom && lhs.right == rhs.right } diff --git a/Source/Internal/External/PDFExternalPageObject.swift b/Source/Internal/External/PDFExternalPageObject.swift index 2e1e898a..84dd7cac 100644 --- a/Source/Internal/External/PDFExternalPageObject.swift +++ b/Source/Internal/External/PDFExternalPageObject.swift @@ -21,7 +21,7 @@ class PDFExternalPageObject: PDFRenderObject { override func calculate(generator _: PDFGenerator, container: PDFContainer) throws -> [PDFLocatedRenderObject] { frame = page.getBoxRect(.mediaBox) return [ - (container, self) + (container, self), ] } diff --git a/Source/Internal/Graphics/PDFContextGraphics.swift b/Source/Internal/Graphics/PDFContextGraphics.swift index 21d31ed2..aaf41b4a 100644 --- a/Source/Internal/Graphics/PDFContextGraphics.swift +++ b/Source/Internal/Graphics/PDFContextGraphics.swift @@ -64,7 +64,7 @@ enum PDFContextGraphics { var mediaBox = bounds let boxData = NSData(bytes: &mediaBox, length: MemoryLayout.size(ofValue: mediaBox)) let pageInfo = [ - kCGPDFContextMediaBox as String: boxData + kCGPDFContextMediaBox as String: boxData, ] context.beginPDFPage(pageInfo as CFDictionary) diff --git a/Source/Internal/Group/PDFGroupObject.swift b/Source/Internal/Group/PDFGroupObject.swift index 498f21ab..c4cec7d0 100644 --- a/Source/Internal/Group/PDFGroupObject.swift +++ b/Source/Internal/Group/PDFGroupObject.swift @@ -59,7 +59,7 @@ class PDFGroupObject: PDFRenderObject { } var groupedResult = [ - [PDFLocatedRenderObject]() + [PDFLocatedRenderObject](), ] // Set padding diff --git a/Source/Internal/Layout/PDFColumnLayoutState.swift b/Source/Internal/Layout/PDFColumnLayoutState.swift index 40878a8f..6d0bdaad 100644 --- a/Source/Internal/Layout/PDFColumnLayoutState.swift +++ b/Source/Internal/Layout/PDFColumnLayoutState.swift @@ -24,27 +24,27 @@ class PDFColumnLayoutState: CustomStringConvertible { self.currentColumn = [ .headerLeft: 0, .contentLeft: 0, - .footerLeft: 0 + .footerLeft: 0, ] self.columnWidths = [ .headerLeft: [], .contentLeft: [], - .footerLeft: [] + .footerLeft: [], ] self.columnSpacings = [ .headerLeft: [], .contentLeft: [], - .footerLeft: [] + .footerLeft: [], ] self.wrapColumnsHeight = [ .headerLeft: 0, .contentLeft: 0, - .footerLeft: 0 + .footerLeft: 0, ] self.inset = [ .headerLeft: (0, 0), .contentLeft: (0, 0), - .footerLeft: (0, 0) + .footerLeft: (0, 0), ] } @@ -53,27 +53,27 @@ class PDFColumnLayoutState: CustomStringConvertible { currentColumn = [ .headerLeft: 0, .contentLeft: 0, - .footerLeft: 0 + .footerLeft: 0, ] columnWidths = [ .headerLeft: [], .contentLeft: [], - .footerLeft: [] + .footerLeft: [], ] columnSpacings = [ .headerLeft: [], .contentLeft: [], - .footerLeft: [] + .footerLeft: [], ] wrapColumnsHeight = [ .headerLeft: 0, .contentLeft: 0, - .footerLeft: 0 + .footerLeft: 0, ] inset = [ .headerLeft: (0, 0), .contentLeft: (0, 0), - .footerLeft: (0, 0) + .footerLeft: (0, 0), ] } diff --git a/Source/Internal/Section/PDFSectionObject.swift b/Source/Internal/Section/PDFSectionObject.swift index 7a842b95..95d4fa92 100644 --- a/Source/Internal/Section/PDFSectionObject.swift +++ b/Source/Internal/Section/PDFSectionObject.swift @@ -122,7 +122,7 @@ class PDFSectionObject: PDFRenderObject { // stores how many objects are in one column at max let maxObjectsPerColumn = objectsPerColumn.reduce(0) { max($0, $1.value.count) } - /* + /* * as soon as a column requests a page break, we need to stack subsequent objects of the very same column until the following is `true`: * one or more columns do not have more objects and all other columns, which have more objects left, are requesting a page break */ diff --git a/Source/Internal/Table/PDFTableObject.swift b/Source/Internal/Table/PDFTableObject.swift index 5389e41f..c9628862 100644 --- a/Source/Internal/Table/PDFTableObject.swift +++ b/Source/Internal/Table/PDFTableObject.swift @@ -267,7 +267,7 @@ class PDFTableObject: PDFRenderObject { let attributes: [NSAttributedString.Key: AnyObject] = [ .foregroundColor: cellStyle.colors.text, .font: cellStyle.font, - .paragraphStyle: paragraph + .paragraphStyle: paragraph, ] return NSAttributedString(string: text, attributes: attributes) } @@ -615,7 +615,7 @@ class PDFTableObject: PDFRenderObject { endPoint: CGPoint(x: frame.maxX, y: frame.maxY)), PDFLineObject(style: borders.left, startPoint: CGPoint(x: frame.minX, y: frame.minY), - endPoint: CGPoint(x: frame.minX, y: frame.maxY)) + endPoint: CGPoint(x: frame.minX, y: frame.maxY)), ] } diff --git a/Source/Internal/Text/PDFAttributedTextObject.swift b/Source/Internal/Text/PDFAttributedTextObject.swift index 580c1cd8..a72cbefa 100644 --- a/Source/Internal/Text/PDFAttributedTextObject.swift +++ b/Source/Internal/Text/PDFAttributedTextObject.swift @@ -287,7 +287,7 @@ class PDFAttributedTextObject: PDFRenderObject { return [ NSAttributedString.Key.font: style?.font ?? fonts[container]!, NSAttributedString.Key.foregroundColor: style?.color ?? textColor[container]!, - NSAttributedString.Key.paragraphStyle: paragraphStyle + NSAttributedString.Key.paragraphStyle: paragraphStyle, ] } diff --git a/Source/Internal/Utils/PDFSlicedObject.swift b/Source/Internal/Utils/PDFSlicedObject.swift index cb21222d..185ab1e8 100644 --- a/Source/Internal/Utils/PDFSlicedObject.swift +++ b/Source/Internal/Utils/PDFSlicedObject.swift @@ -23,7 +23,7 @@ class PDFSlicedObject: PDFRenderObject { override func calculate(generator _: PDFGenerator, container: PDFContainer) throws -> [PDFLocatedRenderObject] { [ - (container, self) + (container, self), ] }