Skip to content

Commit 34ec5f7

Browse files
committed
remove @objc SVGImage
1 parent 38b6f8d commit 34ec5f7

File tree

4 files changed

+63
-26
lines changed

4 files changed

+63
-26
lines changed

SwiftDraw/SVG+CoreGraphics.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,6 @@ public extension CGContext {
6161

6262
public extension SVG {
6363

64-
struct Insets: Equatable {
65-
public var top: CGFloat
66-
public var left: CGFloat
67-
public var bottom: CGFloat
68-
public var right: CGFloat
69-
70-
public init(
71-
top: CGFloat = 0,
72-
left: CGFloat = 0,
73-
bottom: CGFloat = 0,
74-
right: CGFloat = 0
75-
) {
76-
self.top = top
77-
self.left = left
78-
self.bottom = bottom
79-
self.right = right
80-
}
81-
82-
public static let zero = Insets(top: 0, left: 0, bottom: 0, right: 0)
83-
}
84-
8564
func pdfData(size: CGSize? = nil, insets: Insets = .zero) throws -> Data {
8665
let (bounds, pixelsWide, pixelsHigh) = makeBounds(size: size, scale: 1, insets: insets)
8766
var mediaBox = CGRect(x: 0.0, y: 0.0, width: CGFloat(pixelsWide), height: CGFloat(pixelsHigh))

SwiftDraw/SVG+Insets.swift

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//
2+
// SVG+Insets.swift
3+
// SwiftDraw
4+
//
5+
// Created by Simon Whitty on 23/2/25.
6+
// Copyright 2025 Simon Whitty
7+
//
8+
// Distributed under the permissive zlib license
9+
// Get the latest version from here:
10+
//
11+
// https://github.com/swhitty/SwiftDraw
12+
//
13+
// This software is provided 'as-is', without any express or implied
14+
// warranty. In no event will the authors be held liable for any damages
15+
// arising from the use of this software.
16+
//
17+
// Permission is granted to anyone to use this software for any purpose,
18+
// including commercial applications, and to alter it and redistribute it
19+
// freely, subject to the following restrictions:
20+
//
21+
// 1. The origin of this software must not be misrepresented; you must not
22+
// claim that you wrote the original software. If you use this software
23+
// in a product, an acknowledgment in the product documentation would be
24+
// appreciated but is not required.
25+
//
26+
// 2. Altered source versions must be plainly marked as such, and must not be
27+
// misrepresented as being the original software.
28+
//
29+
// 3. This notice may not be removed or altered from any source distribution.
30+
//
31+
32+
import Foundation
33+
34+
#if canImport(CoreGraphics)
35+
import CoreGraphics
36+
#endif
37+
38+
public extension SVG {
39+
struct Insets: Equatable {
40+
public var top: CGFloat
41+
public var left: CGFloat
42+
public var bottom: CGFloat
43+
public var right: CGFloat
44+
45+
public init(
46+
top: CGFloat = 0,
47+
left: CGFloat = 0,
48+
bottom: CGFloat = 0,
49+
right: CGFloat = 0
50+
) {
51+
self.top = top
52+
self.left = left
53+
self.bottom = bottom
54+
self.right = right
55+
}
56+
57+
public static let zero = Insets(top: 0, left: 0, bottom: 0, right: 0)
58+
}
59+
}

SwiftDrawTests/SVGTests.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import XCTest
3333
@testable import SwiftDraw
3434

35+
#if canImport(CoreGraphics)
3536
final class SVGTests: XCTestCase {
3637

3738
func testValidSVGLoads() {
@@ -46,7 +47,6 @@ final class SVGTests: XCTestCase {
4647
XCTAssertNil(SVG(named: "missing.svg", in: .test))
4748
}
4849

49-
#if canImport(CoreGraphics)
5050
func testImageRasterizes() {
5151
let image = SVG.makeLines()
5252
let rendered = image.rasterize(scale: 1)
@@ -71,7 +71,6 @@ final class SVGTests: XCTestCase {
7171
XCTAssertNoThrow(try image.jpegData())
7272
XCTAssertNoThrow(try image.pdfData())
7373
}
74-
#endif
7574

7675
#if canImport(UIKit)
7776
func testRasterize() {
@@ -86,7 +85,6 @@ final class SVGTests: XCTestCase {
8685
XCTAssertEqual(reloaded.scale, 1)
8786
}
8887
#endif
89-
9088
}
9189

9290
private extension SVG {
@@ -98,3 +96,4 @@ private extension SVG {
9896
return SVG(dom: svg, options: .default)
9997
}
10098
}
99+
#endif

SwiftDrawTests/UIImage+ImageTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ final class UIImageTests: XCTestCase {
7474
}
7575
}
7676

77-
#endif
78-
7977
private extension SVG {
8078

8179
static func parse(_ code: String) throws -> SVG {
@@ -90,3 +88,5 @@ private extension SVG {
9088
var errorDescription: String? = "Invalid SVG"
9189
}
9290
}
91+
92+
#endif

0 commit comments

Comments
 (0)