diff --git a/Modules/Capabilities/Observations/Sources/Extensions/GeometryExtensions.swift b/Modules/Capabilities/Observations/Sources/Extensions/GeometryExtensions.swift new file mode 100644 index 00000000..24779c97 --- /dev/null +++ b/Modules/Capabilities/Observations/Sources/Extensions/GeometryExtensions.swift @@ -0,0 +1,25 @@ +// Created by Geoff Pado on 5/8/24. +// Copyright © 2024 Cocoatype, LLC. All rights reserved. + +import CoreGraphics + +extension CGPoint { + static func flippedPoint(from point: CGPoint, scaledTo size: CGSize) -> CGPoint { + var scaledPoint = point + + #if canImport(UIKit) + scaledPoint.y = (1.0 - scaledPoint.y) + #endif + + scaledPoint.x *= size.width + scaledPoint.y *= size.height + + return scaledPoint + } +} + +extension CGSize { + static func * (size: CGSize, multiplier: CGFloat) -> CGSize { + return CGSize(width: size.width * multiplier, height: size.height * multiplier) + } +} diff --git a/Modules/Legacy/Editing/Sources/Extensions/StringExtensions.swift b/Modules/Capabilities/Observations/Sources/Extensions/StringExtensions.swift similarity index 94% rename from Modules/Legacy/Editing/Sources/Extensions/StringExtensions.swift rename to Modules/Capabilities/Observations/Sources/Extensions/StringExtensions.swift index 8def84ee..f274c188 100644 --- a/Modules/Legacy/Editing/Sources/Extensions/StringExtensions.swift +++ b/Modules/Capabilities/Observations/Sources/Extensions/StringExtensions.swift @@ -1,7 +1,7 @@ // Created by Geoff Pado on 5/29/20. // Copyright © 2020 Cocoatype, LLC. All rights reserved. -public extension String { +extension String { var words: [(String, Range)] { var words = [(String, Range)]() enumerateSubstrings(in: startIndex.., imageSize: CGSize) { diff --git a/Modules/Legacy/Editing/Sources/Text Detection/RecognizedText.swift b/Modules/Capabilities/Observations/Sources/RecognizedText.swift similarity index 70% rename from Modules/Legacy/Editing/Sources/Text Detection/RecognizedText.swift rename to Modules/Capabilities/Observations/Sources/RecognizedText.swift index edfeffeb..39c1fe08 100644 --- a/Modules/Legacy/Editing/Sources/Text Detection/RecognizedText.swift +++ b/Modules/Capabilities/Observations/Sources/RecognizedText.swift @@ -3,23 +3,23 @@ import Vision -struct RecognizedText: Equatable { +public struct RecognizedText: Equatable { let recognizedText: VisionText let uuid: UUID var string: String { recognizedText.string } - init(recognizedText: VisionText, uuid: UUID) { + public init(recognizedText: VisionText, uuid: UUID) { self.recognizedText = recognizedText self.uuid = uuid } - static func == (lhs: RecognizedText, rhs: RecognizedText) -> Bool { + public static func == (lhs: RecognizedText, rhs: RecognizedText) -> Bool { lhs.uuid == rhs.uuid } } -protocol VisionText { +public protocol VisionText { func boundingBox(for range: Range) throws -> VNRectangleObservation? var string: String { get } } diff --git a/Modules/Legacy/Editing/Sources/Text Detection/Shape.swift b/Modules/Capabilities/Observations/Sources/Shape.swift similarity index 87% rename from Modules/Legacy/Editing/Sources/Text Detection/Shape.swift rename to Modules/Capabilities/Observations/Sources/Shape.swift index 39b1f683..9419d897 100644 --- a/Modules/Legacy/Editing/Sources/Text Detection/Shape.swift +++ b/Modules/Capabilities/Observations/Sources/Shape.swift @@ -5,12 +5,12 @@ import Foundation import CoreGraphics public struct Shape: Hashable { - let bottomLeft: CGPoint - let bottomRight: CGPoint - let topLeft: CGPoint - let topRight: CGPoint + public let bottomLeft: CGPoint + public let bottomRight: CGPoint + public let topLeft: CGPoint + public let topRight: CGPoint - internal init(bottomLeft: CGPoint, bottomRight: CGPoint, topLeft: CGPoint, topRight: CGPoint) { + public init(bottomLeft: CGPoint, bottomRight: CGPoint, topLeft: CGPoint, topRight: CGPoint) { self.bottomLeft = bottomLeft self.bottomRight = bottomRight self.topLeft = topLeft @@ -26,9 +26,9 @@ public struct Shape: Hashable { ) } - var boundingBox: CGRect { path.boundingBox } + public var boundingBox: CGRect { path.boundingBox } - var path: CGPath { + public var path: CGPath { let path = CGMutablePath() path.move(to: topLeft) path.addLine(to: bottomLeft) @@ -52,7 +52,7 @@ public struct Shape: Hashable { ) } - var angle: Double { + public var angle: Double { guard (centerRight.x - centerLeft.x) != 0 else { return .pi / 2 } // leftyLoosey by @KaenAitch on 2/3/22 // the slope of the primary axis of the shape @@ -60,14 +60,14 @@ public struct Shape: Hashable { return atan(leftyLoosey) } - var center: CGPoint { + public var center: CGPoint { CGPoint( x: (topLeft.x + bottomLeft.x + bottomRight.x + topRight.x) / 4.0, y: (topLeft.y + bottomLeft.y + bottomRight.y + topRight.y) / 4.0 ) } - func union(_ other: Shape) -> Shape { + public func union(_ other: Shape) -> Shape { let transform = CGAffineTransformMakeRotation(angle) let ourRotatedCenterLeft = centerLeft.applying(transform) @@ -95,11 +95,11 @@ public struct Shape: Hashable { } static let zero = Shape(bottomLeft: .zero, bottomRight: .zero, topLeft: .zero, topRight: .zero) - var isNotZero: Bool { + public var isNotZero: Bool { self != Self.zero } - var isNotEmpty: Bool { + public var isNotEmpty: Bool { // https://math.stackexchange.com/a/1259133 let shoelace = bottomLeft.x * bottomRight.y + diff --git a/Modules/Capabilities/Observations/Tests/ShapeTests.swift b/Modules/Capabilities/Observations/Tests/ShapeTests.swift new file mode 100644 index 00000000..46cae456 --- /dev/null +++ b/Modules/Capabilities/Observations/Tests/ShapeTests.swift @@ -0,0 +1,30 @@ +// Created by Geoff Pado on 10/19/23. +// Copyright © 2023 Cocoatype, LLC. All rights reserved. + +import XCTest + +@testable import Observations + +final class ShapeTests: XCTestCase { + func testIsNotEmptyReturnsFalseForEmptyShape() { + let emptyShape = Shape( + bottomLeft: CGPoint(x: 5, y: 5), + bottomRight: CGPoint(x: 5, y: 5), + topLeft: CGPoint(x: 5, y: 5), + topRight: CGPoint(x: 5, y: 5) + ) + + XCTAssertFalse(emptyShape.isNotEmpty) + } + + func testIsNotEmptyReturnsTrueForNonEmptyShape() { + let shape = Shape( + bottomLeft: CGPoint(x: 0, y: 5), + bottomRight: CGPoint(x: 5, y: 5), + topLeft: CGPoint(x: 0, y: 0), + topRight: CGPoint(x: 5, y: 0) + ) + + XCTAssertTrue(shape.isNotEmpty) + } +} diff --git a/Modules/Legacy/Core/Sources/Shortcuts/ShortcutsRedactOperation.swift b/Modules/Legacy/Core/Sources/Shortcuts/ShortcutsRedactOperation.swift index 5a5a7d07..2c79e7d6 100644 --- a/Modules/Legacy/Core/Sources/Shortcuts/ShortcutsRedactOperation.swift +++ b/Modules/Legacy/Core/Sources/Shortcuts/ShortcutsRedactOperation.swift @@ -4,6 +4,7 @@ import Editing import Intents import os.log +import Observations import UIKit import UniformTypeIdentifiers diff --git a/Modules/Legacy/Core/Tests/Shortcuts/ShortcutRedactorTests.swift b/Modules/Legacy/Core/Tests/Shortcuts/ShortcutRedactorTests.swift index ab1c001a..8a1d9350 100644 --- a/Modules/Legacy/Core/Tests/Shortcuts/ShortcutRedactorTests.swift +++ b/Modules/Legacy/Core/Tests/Shortcuts/ShortcutRedactorTests.swift @@ -2,6 +2,7 @@ // Copyright © 2022 Cocoatype, LLC. All rights reserved. import Intents +import Observations import UniformTypeIdentifiers import Vision import XCTest diff --git a/Modules/Legacy/Editing/Sources/BrushStampFactory.swift b/Modules/Legacy/Editing/Sources/BrushStampFactory.swift index e9782e0e..2c7675e7 100644 --- a/Modules/Legacy/Editing/Sources/BrushStampFactory.swift +++ b/Modules/Legacy/Editing/Sources/BrushStampFactory.swift @@ -2,6 +2,7 @@ // Copyright © 2020 Cocoatype, LLC. All rights reserved. import ErrorHandling +import Observations import UIKit public class BrushStampFactory: NSObject { diff --git a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingObservationDebugView.swift b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingObservationDebugView.swift index 472d767d..f342af2d 100644 --- a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingObservationDebugView.swift +++ b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingObservationDebugView.swift @@ -2,6 +2,7 @@ // Copyright © 2022 Cocoatype, LLC. All rights reserved. @_implementationOnly import ClippingBezier +import Observations import UIKit class PhotoEditingObservationDebugView: PhotoEditingRedactionView { diff --git a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingObservationVisualizationView.swift b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingObservationVisualizationView.swift index f43afb17..bf85a413 100644 --- a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingObservationVisualizationView.swift +++ b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingObservationVisualizationView.swift @@ -1,6 +1,7 @@ // Created by Geoff Pado on 4/27/19. // Copyright © 2019 Cocoatype, LLC. All rights reserved. +import Observations import UIKit class PhotoEditingObservationVisualizationView: PhotoEditingRedactionView { diff --git a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingScrollView.swift b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingScrollView.swift index 01ce145d..c49c289e 100644 --- a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingScrollView.swift +++ b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingScrollView.swift @@ -1,6 +1,7 @@ // Created by Geoff Pado on 4/27/19. // Copyright © 2019 Cocoatype, LLC. All rights reserved. +import Observations import UIKit class PhotoEditingScrollView: UIScrollView { diff --git a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingView.swift b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingView.swift index 7efb6264..402bceaf 100644 --- a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingView.swift +++ b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingView.swift @@ -1,6 +1,7 @@ // Created by Geoff Pado on 5/27/19. // Copyright © 2019 Cocoatype, LLC. All rights reserved. +import Observations import UIKit public class PhotoEditingView: UIView, UIScrollViewDelegate { diff --git a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingViewController.swift b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingViewController.swift index 9b191351..41c749fc 100644 --- a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingViewController.swift +++ b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingViewController.swift @@ -3,6 +3,7 @@ import AutoRedactionsUI import Defaults +import Observations import Photos import UIKit diff --git a/Modules/Legacy/Editing/Sources/Editing View/Workspace/PhotoEditingWorkspaceView.swift b/Modules/Legacy/Editing/Sources/Editing View/Workspace/PhotoEditingWorkspaceView.swift index 5f0c208e..4c7d44b2 100644 --- a/Modules/Legacy/Editing/Sources/Editing View/Workspace/PhotoEditingWorkspaceView.swift +++ b/Modules/Legacy/Editing/Sources/Editing View/Workspace/PhotoEditingWorkspaceView.swift @@ -2,6 +2,7 @@ // Copyright © 2019 Cocoatype, LLC. All rights reserved. @_implementationOnly import ClippingBezier +import Observations import UIKit class PhotoEditingWorkspaceView: UIControl, UIGestureRecognizerDelegate { diff --git a/Modules/Legacy/Editing/Sources/Editing View/Workspace/RedactionPathLayer.swift b/Modules/Legacy/Editing/Sources/Editing View/Workspace/RedactionPathLayer.swift index c96010de..06553c37 100644 --- a/Modules/Legacy/Editing/Sources/Editing View/Workspace/RedactionPathLayer.swift +++ b/Modules/Legacy/Editing/Sources/Editing View/Workspace/RedactionPathLayer.swift @@ -1,6 +1,7 @@ // Created by Geoff Pado on 1/2/20. // Copyright © 2020 Cocoatype, LLC. All rights reserved. +import Observations import UIKit class RedactionPathLayer: CALayer { diff --git a/Modules/Legacy/Editing/Sources/Extensions/GeometryExtensions.swift b/Modules/Legacy/Editing/Sources/Extensions/GeometryExtensions.swift index e9f6789e..6f249f76 100644 --- a/Modules/Legacy/Editing/Sources/Extensions/GeometryExtensions.swift +++ b/Modules/Legacy/Editing/Sources/Extensions/GeometryExtensions.swift @@ -1,11 +1,7 @@ // Created by Geoff Pado on 4/10/19. // Copyright © 2019 Cocoatype, LLC. All rights reserved. -#if canImport(AppKit) -import AppKit -#elseif canImport(UIKit) -import UIKit -#endif +import CoreGraphics public extension CGSize { static func * (size: CGSize, multiplier: CGFloat) -> CGSize { @@ -26,19 +22,6 @@ public extension CGPoint { return CGPoint(x: point.x + size.width, y: point.y + size.height) } - static func flippedPoint(from point: CGPoint, scaledTo size: CGSize) -> CGPoint { - var scaledPoint = point - - #if canImport(UIKit) - scaledPoint.y = (1.0 - scaledPoint.y) - #endif - - scaledPoint.x *= size.width - scaledPoint.y *= size.height - - return scaledPoint - } - func isEqual(to otherPoint: CGPoint, accuracy: Double) -> Bool { return (abs(x - otherPoint.x) < accuracy) && (abs(y - otherPoint.y) < accuracy) } diff --git a/Modules/Legacy/Editing/Sources/Extensions/UIBezierPathExtensions.swift b/Modules/Legacy/Editing/Sources/Extensions/UIBezierPathExtensions.swift index bc2470da..427c88e7 100644 --- a/Modules/Legacy/Editing/Sources/Extensions/UIBezierPathExtensions.swift +++ b/Modules/Legacy/Editing/Sources/Extensions/UIBezierPathExtensions.swift @@ -1,6 +1,8 @@ // Created by Geoff Pado on 5/1/19. // Copyright © 2019 Cocoatype, LLC. All rights reserved. +import Observations + #if canImport(AppKit) && !targetEnvironment(macCatalyst) import AppKit @@ -126,7 +128,7 @@ extension UIBezierPath { return shape != nil } - var shape: Shape? { + var shape: Observations.Shape? { let path = Path(self.cgPath) var elements = [Path.Element]() path.forEach { element in diff --git a/Modules/Legacy/Editing/Sources/Redactions/CharacterObservationRedaction.swift b/Modules/Legacy/Editing/Sources/Redactions/CharacterObservationRedaction.swift index 72cc832c..61f70dcf 100644 --- a/Modules/Legacy/Editing/Sources/Redactions/CharacterObservationRedaction.swift +++ b/Modules/Legacy/Editing/Sources/Redactions/CharacterObservationRedaction.swift @@ -1,6 +1,8 @@ // Created by Geoff Pado on 5/15/19. // Copyright © 2019 Cocoatype, LLC. All rights reserved. +import Observations + #if canImport(AppKit) && !targetEnvironment(macCatalyst) import AppKit diff --git a/Modules/Legacy/Editing/Sources/Redactions/Redaction.swift b/Modules/Legacy/Editing/Sources/Redactions/Redaction.swift index 5c637af0..0e4956fe 100644 --- a/Modules/Legacy/Editing/Sources/Redactions/Redaction.swift +++ b/Modules/Legacy/Editing/Sources/Redactions/Redaction.swift @@ -11,9 +11,10 @@ import UIKit public typealias RedactionColor = UIColor public typealias RedactionPath = UIBezierPath - #endif +import Observations + public enum RedactionPart: Equatable { case path(RedactionPath) case shape(Shape) diff --git a/Modules/Legacy/Editing/Sources/Redactions/TextObservationRedaction.swift b/Modules/Legacy/Editing/Sources/Redactions/TextObservationRedaction.swift index a584adcd..a9bbb4d4 100644 --- a/Modules/Legacy/Editing/Sources/Redactions/TextObservationRedaction.swift +++ b/Modules/Legacy/Editing/Sources/Redactions/TextObservationRedaction.swift @@ -1,6 +1,8 @@ // Created by Geoff Pado on 7/29/19. // Copyright © 2019 Cocoatype, LLC. All rights reserved. +import Observations + #if canImport(AppKit) && !targetEnvironment(macCatalyst) import AppKit diff --git a/Modules/Legacy/Editing/Sources/Redactions/WordObservationRedaction.swift b/Modules/Legacy/Editing/Sources/Redactions/WordObservationRedaction.swift index 4e9a00ca..e3e693cb 100644 --- a/Modules/Legacy/Editing/Sources/Redactions/WordObservationRedaction.swift +++ b/Modules/Legacy/Editing/Sources/Redactions/WordObservationRedaction.swift @@ -1,9 +1,9 @@ // Created by Geoff Pado on 5/29/20. // Copyright © 2020 Cocoatype, LLC. All rights reserved. +import Observations import UIKit -#if canImport(UIKit) extension Redaction { init(_ wordObservations: [WordObservation], color: UIColor) { let parts = wordObservations.reduce(into: [UUID: [WordObservation]]()) { result, wordObservation in @@ -20,4 +20,3 @@ extension Redaction { self.init(color: color, parts: parts) } } -#endif diff --git a/Modules/Legacy/Editing/Sources/Text Detection/TextDetector.swift b/Modules/Legacy/Editing/Sources/Text Detection/TextDetector.swift index dfffa224..e6451e75 100644 --- a/Modules/Legacy/Editing/Sources/Text Detection/TextDetector.swift +++ b/Modules/Legacy/Editing/Sources/Text Detection/TextDetector.swift @@ -1,6 +1,7 @@ // Created by Geoff Pado on 4/22/19. // Copyright © 2019 Cocoatype, LLC. All rights reserved. +import Observations import Vision #if canImport(AppKit) diff --git a/Modules/Legacy/Editing/Sources/Text Detection/WordObservationAccessibilityElement.swift b/Modules/Legacy/Editing/Sources/Text Detection/WordObservationAccessibilityElement.swift index 734bba78..41997c80 100644 --- a/Modules/Legacy/Editing/Sources/Text Detection/WordObservationAccessibilityElement.swift +++ b/Modules/Legacy/Editing/Sources/Text Detection/WordObservationAccessibilityElement.swift @@ -1,6 +1,8 @@ // Created by Geoff Pado on 8/4/19. // Copyright © 2019 Cocoatype, LLC. All rights reserved. +#if canImport(UIKit) +import Observations import UIKit class WordObservationAccessibilityElement: UIAccessibilityElement { @@ -39,3 +41,4 @@ class WordObservationAccessibilityElement: UIAccessibilityElement { lhs.wordObservation.textObservationUUID == rhs.wordObservation.textObservationUUID } } +#endif diff --git a/Modules/Legacy/Editing/Tests/BrushStampFactoryTests.swift b/Modules/Legacy/Editing/Tests/BrushStampFactoryTests.swift index ffc6f7dd..e7c4bdd8 100644 --- a/Modules/Legacy/Editing/Tests/BrushStampFactoryTests.swift +++ b/Modules/Legacy/Editing/Tests/BrushStampFactoryTests.swift @@ -1,6 +1,7 @@ // Created by Geoff Pado on 5/13/23. // Copyright © 2023 Cocoatype, LLC. All rights reserved. +import Observations import XCTest @testable import Editing diff --git a/Modules/Legacy/Editing/Tests/Redactions/CharacterObservationRedactionTests.swift b/Modules/Legacy/Editing/Tests/Redactions/CharacterObservationRedactionTests.swift index 5b3c1fc8..603ed412 100644 --- a/Modules/Legacy/Editing/Tests/Redactions/CharacterObservationRedactionTests.swift +++ b/Modules/Legacy/Editing/Tests/Redactions/CharacterObservationRedactionTests.swift @@ -4,6 +4,7 @@ import XCTest @testable import Editing +@testable import Observations final class CharacterObservationRedactionTests: XCTestCase { #if canImport(UIKit) diff --git a/Modules/Legacy/Editing/Tests/Redactions/RestoredRedactionTests.swift b/Modules/Legacy/Editing/Tests/Redactions/RestoredRedactionTests.swift index 19b6af17..64c10334 100644 --- a/Modules/Legacy/Editing/Tests/Redactions/RestoredRedactionTests.swift +++ b/Modules/Legacy/Editing/Tests/Redactions/RestoredRedactionTests.swift @@ -4,6 +4,7 @@ import XCTest @testable import Editing +@testable import Observations final class RestoredRedactionTests: XCTestCase { #if canImport(UIKit) diff --git a/Modules/Legacy/Editing/Tests/Redactions/TextObservationRedactionTests.swift b/Modules/Legacy/Editing/Tests/Redactions/TextObservationRedactionTests.swift index 3a1e6ce9..82282503 100644 --- a/Modules/Legacy/Editing/Tests/Redactions/TextObservationRedactionTests.swift +++ b/Modules/Legacy/Editing/Tests/Redactions/TextObservationRedactionTests.swift @@ -1,6 +1,7 @@ // Created by Geoff Pado on 10/19/23. // Copyright © 2023 Cocoatype, LLC. All rights reserved. +import Observations import XCTest @testable import Editing diff --git a/Modules/Legacy/Editing/Tests/Redactions/WordObservationRedactionTests.swift b/Modules/Legacy/Editing/Tests/Redactions/WordObservationRedactionTests.swift index 73de9a8c..cc6c47d8 100644 --- a/Modules/Legacy/Editing/Tests/Redactions/WordObservationRedactionTests.swift +++ b/Modules/Legacy/Editing/Tests/Redactions/WordObservationRedactionTests.swift @@ -5,11 +5,12 @@ import Vision import XCTest @testable import Editing +@testable import Observations final class WordObservationRedactionTests: XCTestCase { #if canImport(UIKit) func testInitIgnoresEmptyShapes() throws { - let observation = try mockObservation(shape: TestHelpers.emptyShape) + let observation = try mockObservation(shape: TestHelpers.emptyShape) let redaction = Redaction([observation], color: .black) XCTAssertEqual(redaction.parts.count, 0) diff --git a/Modules/Legacy/Editing/Tests/TestHelpers.swift b/Modules/Legacy/Editing/Tests/TestHelpers.swift index 1bb5738a..4a158a14 100644 --- a/Modules/Legacy/Editing/Tests/TestHelpers.swift +++ b/Modules/Legacy/Editing/Tests/TestHelpers.swift @@ -1,6 +1,7 @@ // Created by Geoff Pado on 4/11/21. // Copyright © 2021 Cocoatype, LLC. All rights reserved. +import Observations import XCTest @testable import Editing diff --git a/Modules/Legacy/Editing/Tests/Text Detection/ShapeTests.swift b/Modules/Legacy/Editing/Tests/Text Detection/ShapeTests.swift deleted file mode 100644 index 5f5fb6bb..00000000 --- a/Modules/Legacy/Editing/Tests/Text Detection/ShapeTests.swift +++ /dev/null @@ -1,16 +0,0 @@ -// Created by Geoff Pado on 10/19/23. -// Copyright © 2023 Cocoatype, LLC. All rights reserved. - -import XCTest - -@testable import Editing - -final class ShapeTests: XCTestCase { - func testIsNotEmptyReturnsFalseForEmptyShape() { - XCTAssertFalse(TestHelpers.emptyShape.isNotEmpty) - } - - func testIsNotEmptyReturnsTrueForNonEmptyShape() { - XCTAssertTrue(TestHelpers.shape.isNotEmpty) - } -} diff --git a/Project.swift b/Project.swift index 1334ab06..7e1f77cd 100644 --- a/Project.swift +++ b/Project.swift @@ -41,6 +41,7 @@ let project = Project( Editing.target, ErrorHandling.target, Logging.target, + Observations.target, Receipts.target, Redacting.target, TestHelpers.target, @@ -51,6 +52,7 @@ let project = Project( Editing.testTarget, ErrorHandling.testTarget, Logging.testTarget, + Observations.testTarget, ], schemes: [ .scheme( diff --git a/Tuist/ProjectDescriptionHelpers/TargetExtensions.swift b/Tuist/ProjectDescriptionHelpers/TargetExtensions.swift index 3e3be77a..5f172423 100644 --- a/Tuist/ProjectDescriptionHelpers/TargetExtensions.swift +++ b/Tuist/ProjectDescriptionHelpers/TargetExtensions.swift @@ -1,7 +1,28 @@ import ProjectDescription extension Target { - static func moduleTestTarget(name: String, type: String = "Capabilities", dependencies: [ProjectDescription.TargetDependency] = []) -> Target { + static func capabilitiesTarget( + name: String, + dependencies: [TargetDependency] = [] + ) -> Target { + Target.target( + name: name, + destinations: [.iPhone, .iPad, .macCatalyst, .appleVisionWithiPadDesign, .mac], + product: .framework, + bundleId: "com.cocoatype.Highlighter.\(name)", + sources: ["Modules/Capabilities/\(name)/Sources/**"], + dependencies: dependencies + ) + } + + static func capabilitiesTestTarget( + name: String, + dependencies: [TargetDependency] = [] + ) -> Target { + moduleTestTarget(name: name, type: "Capabilities", dependencies: dependencies) + } + + static func moduleTestTarget(name: String, type: String, dependencies: [TargetDependency] = []) -> Target { return Target.target( name: "\(name)Tests", destinations: [.iPhone, .iPad, .macCatalyst, .appleVisionWithiPadDesign], diff --git a/Tuist/ProjectDescriptionHelpers/Targets/AppRatings.swift b/Tuist/ProjectDescriptionHelpers/Targets/AppRatings.swift index bf2034e6..89c84058 100644 --- a/Tuist/ProjectDescriptionHelpers/Targets/AppRatings.swift +++ b/Tuist/ProjectDescriptionHelpers/Targets/AppRatings.swift @@ -12,7 +12,7 @@ public enum AppRatings { ] ) - public static let testTarget = Target.moduleTestTarget(name: "AppRatings", dependencies: [ + public static let testTarget = Target.capabilitiesTestTarget(name: "AppRatings", dependencies: [ .target(Defaults.target), .target(Editing.target), .target(TestHelpers.target), diff --git a/Tuist/ProjectDescriptionHelpers/Targets/AutoRedactionsUI.swift b/Tuist/ProjectDescriptionHelpers/Targets/AutoRedactionsUI.swift index aa7b59be..b66878cc 100644 --- a/Tuist/ProjectDescriptionHelpers/Targets/AutoRedactionsUI.swift +++ b/Tuist/ProjectDescriptionHelpers/Targets/AutoRedactionsUI.swift @@ -13,5 +13,5 @@ public enum AutoRedactionsUI { ] ) - public static let testTarget = Target.moduleTestTarget(name: "AutoRedactionsUI") + public static let testTarget = Target.capabilitiesTestTarget(name: "AutoRedactionsUI") } diff --git a/Tuist/ProjectDescriptionHelpers/Targets/Editing.swift b/Tuist/ProjectDescriptionHelpers/Targets/Editing.swift index 310be6ff..1602c38e 100644 --- a/Tuist/ProjectDescriptionHelpers/Targets/Editing.swift +++ b/Tuist/ProjectDescriptionHelpers/Targets/Editing.swift @@ -3,7 +3,7 @@ import ProjectDescription public enum Editing { public static let target = Target.target( name: "Editing", - destinations: [.iPhone, .iPad, .macCatalyst, .appleVisionWithiPadDesign], + destinations: [.iPhone, .iPad, .macCatalyst, .appleVisionWithiPadDesign, .mac], product: .framework, bundleId: "com.cocoatype.Highlighter.Editing", sources: ["Modules/Legacy/Editing/Sources/**"], @@ -12,6 +12,7 @@ public enum Editing { dependencies: [ .target(AutoRedactionsUI.target), .target(ErrorHandling.target), + .target(Observations.target), .package(product: "ClippingBezier", type: .runtime), .package(product: "Introspect", type: .runtime), ], diff --git a/Tuist/ProjectDescriptionHelpers/Targets/ErrorHandling.swift b/Tuist/ProjectDescriptionHelpers/Targets/ErrorHandling.swift index ecb37646..38f19f54 100644 --- a/Tuist/ProjectDescriptionHelpers/Targets/ErrorHandling.swift +++ b/Tuist/ProjectDescriptionHelpers/Targets/ErrorHandling.swift @@ -12,5 +12,5 @@ public enum ErrorHandling { ] ) - public static let testTarget = Target.moduleTestTarget(name: "ErrorHandling") + public static let testTarget = Target.capabilitiesTestTarget(name: "ErrorHandling") } diff --git a/Tuist/ProjectDescriptionHelpers/Targets/Logging.swift b/Tuist/ProjectDescriptionHelpers/Targets/Logging.swift index 63e7c234..0647e2f3 100644 --- a/Tuist/ProjectDescriptionHelpers/Targets/Logging.swift +++ b/Tuist/ProjectDescriptionHelpers/Targets/Logging.swift @@ -12,5 +12,5 @@ public enum Logging { ] ) - public static let testTarget = Target.moduleTestTarget(name: "Logging") + public static let testTarget = Target.capabilitiesTestTarget(name: "Logging") } diff --git a/Tuist/ProjectDescriptionHelpers/Targets/Observations.swift b/Tuist/ProjectDescriptionHelpers/Targets/Observations.swift new file mode 100644 index 00000000..ba3330c7 --- /dev/null +++ b/Tuist/ProjectDescriptionHelpers/Targets/Observations.swift @@ -0,0 +1,7 @@ +import ProjectDescription + +public enum Observations { + public static let target = Target.capabilitiesTarget(name: "Observations") + + public static let testTarget = Target.capabilitiesTestTarget(name: "Observations") +} diff --git a/Tuist/ProjectDescriptionHelpers/Targets/Redacting.swift b/Tuist/ProjectDescriptionHelpers/Targets/Redacting.swift index 759aa254..430c986e 100644 --- a/Tuist/ProjectDescriptionHelpers/Targets/Redacting.swift +++ b/Tuist/ProjectDescriptionHelpers/Targets/Redacting.swift @@ -7,7 +7,7 @@ import ProjectDescription -public struct Redacting { +public enum Redacting { public static let target = Target.target( name: "Redacting", destinations: [.mac], @@ -36,6 +36,7 @@ public struct Redacting { resources: ["Modules/Legacy/Editing/Resources/**"], dependencies: [ .target(ErrorHandling.target), + .target(Observations.target), ] ) }