From 01658fd7310483e04503b419b586a7accc67eb87 Mon Sep 17 00:00:00 2001 From: hfutrell Date: Fri, 18 Oct 2024 14:46:11 -0700 Subject: [PATCH 01/12] up iOS deployment target to 12, fix SwiftLint XCode project integration, add Sendable support, fix linter warnings, fix new XCode 16 warnings. --- BezierKit.podspec | 4 +- BezierKit/BezierKit.xcodeproj/project.pbxproj | 180 ++++++++++++------ .../contents.xcworkspacedata | 2 +- .../xcschemes/BezierKitMacDemos.xcscheme | 2 +- .../xcschemes/BezierKit_Mac.xcscheme | 2 +- .../xcschemes/BezierKit_MacTests.xcscheme | 2 +- .../xcschemes/BezierKit_iOS.xcscheme | 2 +- .../xcschemes/BezierKit_iOSTests.xcscheme | 2 +- BezierKit/BezierKitTests/Path+DataTests.swift | 4 +- BezierKit/Library/BezierCurve.swift | 4 +- BezierKit/Library/BezierKit-ObjC.swift | 8 +- BezierKit/Library/BoundingBoxHierarchy.swift | 4 - BezierKit/Library/CGPoint+Overloads.swift | 2 - BezierKit/Library/CubicCurve.swift | 2 +- BezierKit/Library/LineSegment.swift | 2 +- BezierKit/Library/Lock.swift | 4 +- BezierKit/Library/Path.swift | 6 +- BezierKit/Library/PathComponent.swift | 16 +- BezierKit/Library/Polynomial.swift | 12 +- BezierKit/Library/QuadraticCurve.swift | 2 +- BezierKit/Library/Shape.swift | 6 +- BezierKit/Library/Types.swift | 6 +- BezierKit/Library/Utils.swift | 2 +- Package.swift | 2 +- 24 files changed, 170 insertions(+), 108 deletions(-) diff --git a/BezierKit.podspec b/BezierKit.podspec index 6b4c0c83..f2a767b3 100644 --- a/BezierKit.podspec +++ b/BezierKit.podspec @@ -5,14 +5,14 @@ Pod::Spec.new do |s| s.name = "BezierKit" - s.version = "0.15.0" + s.version = "0.16.0" s.summary = "comprehensive Bezier Path library written in Swift" s.homepage = "https://github.com/hfutrell/BezierKit" s.license = "MIT" s.author = { "Holmes Futrell" => "holmesfutrell@gmail.com" } s.swift_version = "5.3" - s.ios.deployment_target = "10.0" + s.ios.deployment_target = "12.0" s.osx.deployment_target = "10.12" s.ios.framework = 'UIKit', 'CoreGraphics' s.osx.framework = 'AppKit' diff --git a/BezierKit/BezierKit.xcodeproj/project.pbxproj b/BezierKit/BezierKit.xcodeproj/project.pbxproj index 4078d959..6d29da77 100644 --- a/BezierKit/BezierKit.xcodeproj/project.pbxproj +++ b/BezierKit/BezierKit.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -467,11 +467,11 @@ FD2625371EAC7B9A00C64652 /* Frameworks */, FD2625381EAC7B9A00C64652 /* Headers */, FD2625391EAC7B9A00C64652 /* Resources */, - FD57BE8D2357ADED00E96C81 /* ShellScript */, ); buildRules = ( ); dependencies = ( + FDE1B7052CC30BDE00498FE3 /* PBXTargetDependency */, ); name = BezierKit_iOS; productName = BezierKit_iOS; @@ -486,11 +486,11 @@ FD4A0DBC1EAAD01F0031A393 /* Frameworks */, FD4A0DBD1EAAD01F0031A393 /* Headers */, FD4A0DBE1EAAD01F0031A393 /* Resources */, - FD57BE8E2357AE0500E96C81 /* ShellScript */, ); buildRules = ( ); dependencies = ( + FDE1B7072CC30BE200498FE3 /* PBXTargetDependency */, ); name = BezierKit_Mac; productName = BezierKit_Mac; @@ -539,8 +539,9 @@ FD0F54ED1DC43FFB0084CDCD /* Project object */ = { isa = PBXProject; attributes = { + BuildIndependentTargetsInParallel = YES; LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 1340; + LastUpgradeCheck = 1600; ORGANIZATIONNAME = "Holmes Futrell"; TargetAttributes = { FD0F54F41DC43FFB0084CDCD = { @@ -579,6 +580,9 @@ Base, ); mainGroup = FD0F54EC1DC43FFB0084CDCD; + packageReferences = ( + FDE1B7032CC30B5900498FE3 /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */, + ); productRefGroup = FD0F54F61DC43FFB0084CDCD /* Products */; projectDirPath = ""; projectRoot = ""; @@ -632,43 +636,6 @@ }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - FD57BE8D2357ADED00E96C81 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; - }; - FD57BE8E2357AE0500E96C81 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ FD0F54F11DC43FFB0084CDCD /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -829,6 +796,14 @@ target = FD4A0DBF1EAAD01F0031A393 /* BezierKit_Mac */; targetProxy = FDB9D7451EB28D1900413F0E /* PBXContainerItemProxy */; }; + FDE1B7052CC30BDE00498FE3 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + productRef = FDE1B7042CC30BDE00498FE3 /* SwiftLintBuildToolPlugin */; + }; + FDE1B7072CC30BE200498FE3 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + productRef = FDE1B7062CC30BE200498FE3 /* SwiftLintBuildToolPlugin */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -877,9 +852,11 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "-"; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -894,7 +871,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MACOSX_DEPLOYMENT_TARGET = 10.12; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; @@ -940,9 +917,11 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "-"; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -951,11 +930,12 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MACOSX_DEPLOYMENT_TARGET = 10.12; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; SWIFT_VERSION = ""; }; @@ -964,12 +944,16 @@ FD0F550E1DC43FFB0084CDCD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "-"; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; INFOPLIST_FILE = MacDemos/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = HolmesFutrell.BezierKitMacDemos; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -979,12 +963,16 @@ FD0F550F1DC43FFB0084CDCD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "-"; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; INFOPLIST_FILE = MacDemos/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = HolmesFutrell.BezierKitMacDemos; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -1003,15 +991,22 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; INFOPLIST_FILE = BezierKit_iOS/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 11.0; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; PRODUCT_BUNDLE_IDENTIFIER = com.HolmesFutrell.BezierKit; PRODUCT_NAME = BezierKit; SDKROOT = iphoneos; SKIP_INSTALL = YES; SUPPORTS_MACCATALYST = NO; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1030,15 +1025,22 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; INFOPLIST_FILE = BezierKit_iOS/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 11.0; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; PRODUCT_BUNDLE_IDENTIFIER = com.HolmesFutrell.BezierKit; PRODUCT_NAME = BezierKit; SDKROOT = iphoneos; SKIP_INSTALL = YES; SUPPORTS_MACCATALYST = NO; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -1054,14 +1056,22 @@ CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; FRAMEWORK_VERSION = A; INFOPLIST_FILE = BezierKit_Mac/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 11.0; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; PRODUCT_BUNDLE_IDENTIFIER = com.HolmesFutrell.BezierKit; PRODUCT_NAME = BezierKit; SKIP_INSTALL = YES; @@ -1079,14 +1089,22 @@ CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; FRAMEWORK_VERSION = A; INFOPLIST_FILE = BezierKit_Mac/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 11.0; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; PRODUCT_BUNDLE_IDENTIFIER = com.HolmesFutrell.BezierKit; PRODUCT_NAME = BezierKit; SKIP_INSTALL = YES; @@ -1102,7 +1120,12 @@ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; INFOPLIST_FILE = BezierKit_iOSTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = "com.HolmesFutrell.BezierKit-iOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -1116,7 +1139,12 @@ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; INFOPLIST_FILE = BezierKit_iOSTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = "com.HolmesFutrell.BezierKit-iOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -1130,8 +1158,14 @@ buildSettings = { CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; INFOPLIST_FILE = BezierKit_MacTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = "com.HolmesFutrell.BezierKit-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; @@ -1144,8 +1178,14 @@ buildSettings = { CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; INFOPLIST_FILE = BezierKit_MacTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = "com.HolmesFutrell.BezierKit-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; @@ -1211,6 +1251,30 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + FDE1B7032CC30B5900498FE3 /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/SimplyDanny/SwiftLintPlugins"; + requirement = { + kind = exactVersion; + version = 0.57.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + FDE1B7042CC30BDE00498FE3 /* SwiftLintBuildToolPlugin */ = { + isa = XCSwiftPackageProductDependency; + package = FDE1B7032CC30B5900498FE3 /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */; + productName = "plugin:SwiftLintBuildToolPlugin"; + }; + FDE1B7062CC30BE200498FE3 /* SwiftLintBuildToolPlugin */ = { + isa = XCSwiftPackageProductDependency; + package = FDE1B7032CC30B5900498FE3 /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */; + productName = "plugin:SwiftLintBuildToolPlugin"; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = FD0F54ED1DC43FFB0084CDCD /* Project object */; } diff --git a/BezierKit/BezierKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/BezierKit/BezierKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 890c3b9a..919434a6 100644 --- a/BezierKit/BezierKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/BezierKit/BezierKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/BezierKit/BezierKit.xcodeproj/xcshareddata/xcschemes/BezierKitMacDemos.xcscheme b/BezierKit/BezierKit.xcodeproj/xcshareddata/xcschemes/BezierKitMacDemos.xcscheme index b88fcc75..534b029a 100644 --- a/BezierKit/BezierKit.xcodeproj/xcshareddata/xcschemes/BezierKitMacDemos.xcscheme +++ b/BezierKit/BezierKit.xcodeproj/xcshareddata/xcschemes/BezierKitMacDemos.xcscheme @@ -1,6 +1,6 @@ where CurveType: BezierCurve { +public struct Subcurve: Sendable where CurveType: BezierCurve { public let t1: CGFloat public let t2: CGFloat public let curve: CurveType @@ -282,7 +282,7 @@ public protocol Reversible { func reversed() -> Self } -public protocol BezierCurve: BoundingBoxProtocol, Transformable, Reversible { +public protocol BezierCurve: BoundingBoxProtocol, Transformable, Reversible, Sendable { var simple: Bool { get } var points: [CGPoint] { get } var startingPoint: CGPoint { get set } diff --git a/BezierKit/Library/BezierKit-ObjC.swift b/BezierKit/Library/BezierKit-ObjC.swift index 90d2ec4a..26484455 100644 --- a/BezierKit/Library/BezierKit-ObjC.swift +++ b/BezierKit/Library/BezierKit-ObjC.swift @@ -15,7 +15,7 @@ import Foundation #if !os(WASI) && !os(Linux) // MARK: Path.swift -@available (*, unavailable) +@available(*, unavailable) @objc public extension Path { @objc(isEmpty) var _objc_isEmpty: Bool { @@ -66,7 +66,7 @@ import Foundation } // MARK: Path+VectorBoolean.swift -@available (*, unavailable) +@available(*, unavailable) public extension Path { @objc(subtractPath:accuracy:) func _objc_subtract(_ other: Path, accuracy: CGFloat=BezierKit.defaultIntersectionAccuracy) -> Path { return subtract(other, accuracy: accuracy) @@ -83,7 +83,7 @@ public extension Path { } // MARK: Path+Data.swift -@available (*, unavailable) +@available(*, unavailable) public extension Path { @objc(initWithData:) convenience init?(_objc_data: Data) { self.init(data: _objc_data) @@ -94,7 +94,7 @@ public extension Path { } // MARK: Path+Projection.swift -@available (*, unavailable) +@available(*, unavailable) public extension Path { @objc(point:isWithinDistanceOfBoundary:) func _objc_pointIsWithinDistanceOfBoundary(_ point: CGPoint, distance: CGFloat) -> Bool { return pointIsWithinDistanceOfBoundary(point, distance: distance) diff --git a/BezierKit/Library/BoundingBoxHierarchy.swift b/BezierKit/Library/BoundingBoxHierarchy.swift index 88641174..5c73c660 100644 --- a/BezierKit/Library/BoundingBoxHierarchy.swift +++ b/BezierKit/Library/BoundingBoxHierarchy.swift @@ -46,10 +46,6 @@ final internal class BoundingBoxHierarchy { internal struct Node: Equatable { let boundingBox: BoundingBox let type: NodeType - init(boundingBox: BoundingBox, type: NodeType) { - self.type = type - self.boundingBox = boundingBox - } } private let boundingBoxes: UnsafePointer diff --git a/BezierKit/Library/CGPoint+Overloads.swift b/BezierKit/Library/CGPoint+Overloads.swift index 0d92c3f8..73d490a3 100644 --- a/BezierKit/Library/CGPoint+Overloads.swift +++ b/BezierKit/Library/CGPoint+Overloads.swift @@ -11,8 +11,6 @@ import CoreGraphics #endif import Foundation -// swiftlint:disable shorthand_operator - public extension CGPoint { var length: CGFloat { return sqrt(self.lengthSquared) diff --git a/BezierKit/Library/CubicCurve.swift b/BezierKit/Library/CubicCurve.swift index efd88994..ef5b46eb 100644 --- a/BezierKit/Library/CubicCurve.swift +++ b/BezierKit/Library/CubicCurve.swift @@ -14,7 +14,7 @@ import Foundation /** Cubic Bézier Curve */ -public struct CubicCurve: NonlinearBezierCurve, Equatable { +public struct CubicCurve: NonlinearBezierCurve, Equatable, Sendable { public var p0, p1, p2, p3: CGPoint diff --git a/BezierKit/Library/LineSegment.swift b/BezierKit/Library/LineSegment.swift index cae2f55a..c0c7f132 100644 --- a/BezierKit/Library/LineSegment.swift +++ b/BezierKit/Library/LineSegment.swift @@ -11,7 +11,7 @@ import CoreGraphics #endif import Foundation -public struct LineSegment: BezierCurve, Equatable { +public struct LineSegment: BezierCurve, Equatable, Sendable { public var p0, p1: CGPoint diff --git a/BezierKit/Library/Lock.swift b/BezierKit/Library/Lock.swift index 368d5ab0..bb6eb091 100644 --- a/BezierKit/Library/Lock.swift +++ b/BezierKit/Library/Lock.swift @@ -9,7 +9,7 @@ import Foundation #if canImport(Darwin) -internal class UnfairLock { +internal final class UnfairLock { private let lockPointer: UnsafeMutablePointer init() { lockPointer = UnsafeMutablePointer.allocate(capacity: 1) @@ -25,7 +25,7 @@ internal class UnfairLock { } } #else -internal class UnfairLock { +internal final class UnfairLock { private let lock = NSLock() func sync(_ f: () throws -> T) rethrows -> T { lock.lock() diff --git a/BezierKit/Library/Path.swift b/BezierKit/Library/Path.swift index 6ebf8d94..c9590818 100644 --- a/BezierKit/Library/Path.swift +++ b/BezierKit/Library/Path.swift @@ -33,7 +33,7 @@ internal func windingCountImpliesContainment(_ count: Int, using rule: PathFillR } } -open class Path: NSObject { +open class Path: NSObject, @unchecked Sendable { /// lock to make external accessing of lazy vars threadsafe private let lock = UnfairLock() @@ -383,7 +383,7 @@ extension Path: Reversible { } } -public struct IndexedPathLocation: Equatable, Comparable { +public struct IndexedPathLocation: Equatable, Comparable, Sendable { public let componentIndex: Int public let elementIndex: Int public let t: CGFloat @@ -413,7 +413,7 @@ public struct IndexedPathLocation: Equatable, Comparable { } } -public struct PathIntersection: Equatable { +public struct PathIntersection: Equatable, Sendable { public let indexedPathLocation1, indexedPathLocation2: IndexedPathLocation internal init(indexedPathLocation1: IndexedPathLocation, indexedPathLocation2: IndexedPathLocation) { self.indexedPathLocation1 = indexedPathLocation1 diff --git a/BezierKit/Library/PathComponent.swift b/BezierKit/Library/PathComponent.swift index bf064419..74fbe65d 100644 --- a/BezierKit/Library/PathComponent.swift +++ b/BezierKit/Library/PathComponent.swift @@ -11,7 +11,7 @@ import CoreGraphics #endif import Foundation -open class PathComponent: NSObject, Reversible, Transformable { +open class PathComponent: NSObject, Reversible, Transformable, @unchecked Sendable { private let offsets: [Int] public let points: [CGPoint] @@ -330,11 +330,11 @@ open class PathComponent: NSObject, Reversible, Transformable { let pathComponentIntersections = elementIntersections.compactMap { (i: Intersection) -> PathComponentIntersection? in let i1 = IndexedPathComponentLocation(elementIndex: i1, t: i.t1) let i2 = IndexedPathComponentLocation(elementIndex: i2, t: i.t2) - if i1.t == 0.0, (isClosed1 || i1.elementIndex > 0) { + if i1.t == 0.0, isClosed1 || i1.elementIndex > 0 { // handle this intersection instead at i1.elementIndex-1 w/ t=1 return nil } - if i2.t == 0.0, (isClosed2 || i2.elementIndex > 0) { + if i2.t == 0.0, isClosed2 || i2.elementIndex > 0 { // handle this intersection instead at i2.elementIndex-1 w/ t=1 return nil } @@ -353,11 +353,13 @@ open class PathComponent: NSObject, Reversible, Transformable { } let numPoints = self.order(at: i2) + 1 let offset = self.offsets[i2] + // swiftlint:disable for_where for i in 1.. 0 || isClosed) { + if $0.t1 == 0.0, i1 > 0 || isClosed { // handle the intersections instead at i1-1, t=1 return false } @@ -587,7 +589,7 @@ open class PathComponent: NSObject, Reversible, Transformable { } } -public struct IndexedPathComponentLocation: Equatable, Comparable { +public struct IndexedPathComponentLocation: Equatable, Comparable, Sendable { public let elementIndex: Int public let t: CGFloat public init(elementIndex: Int, t: CGFloat) { @@ -604,11 +606,11 @@ public struct IndexedPathComponentLocation: Equatable, Comparable { } } -public struct PathComponentIntersection { +public struct PathComponentIntersection: Sendable { let indexedComponentLocation1, indexedComponentLocation2: IndexedPathComponentLocation } -public struct PathComponentRange: Equatable { +public struct PathComponentRange: Equatable, Sendable { public var start: IndexedPathComponentLocation public var end: IndexedPathComponentLocation public init(from start: IndexedPathComponentLocation, to end: IndexedPathComponentLocation) { diff --git a/BezierKit/Library/Polynomial.swift b/BezierKit/Library/Polynomial.swift index d1483183..49881b83 100644 --- a/BezierKit/Library/Polynomial.swift +++ b/BezierKit/Library/Polynomial.swift @@ -118,7 +118,7 @@ public extension BernsteinPolynomial { // } } -public struct BernsteinPolynomial0: BernsteinPolynomial { +public struct BernsteinPolynomial0: BernsteinPolynomial, Sendable { // func enumerated(block: (Int, CGFloat) -> Void) { // block(0, b0) // } @@ -142,7 +142,7 @@ public struct BernsteinPolynomial0: BernsteinPolynomial { } } -public struct BernsteinPolynomial1: BernsteinPolynomial { +public struct BernsteinPolynomial1: BernsteinPolynomial, Sendable { // func enumerated(block: (Int, CGFloat) -> Void) { // block(0, b0) // block(1, b1) @@ -177,7 +177,7 @@ public struct BernsteinPolynomial1: BernsteinPolynomial { public var order: Int { return 1 } } -public struct BernsteinPolynomial2: BernsteinPolynomial { +public struct BernsteinPolynomial2: BernsteinPolynomial, Sendable { // func enumerated(block: (Int, CGFloat) -> Void) { // block(0, b0) // block(1, b1) @@ -210,7 +210,7 @@ public struct BernsteinPolynomial2: BernsteinPolynomial { public var order: Int { return 2 } } -public struct BernsteinPolynomial3: BernsteinPolynomial { +public struct BernsteinPolynomial3: BernsteinPolynomial, Sendable { // func enumerated(block: (Int, CGFloat) -> Void) { // block(0, b0) // block(1, b1) @@ -248,7 +248,7 @@ public struct BernsteinPolynomial3: BernsteinPolynomial { public var order: Int { return 3 } } -public struct BernsteinPolynomial4: BernsteinPolynomial { +public struct BernsteinPolynomial4: BernsteinPolynomial, Sendable { // func enumerated(block: (Int, CGFloat) -> Void) { // block(0, b0) // block(1, b1) @@ -291,7 +291,7 @@ public struct BernsteinPolynomial4: BernsteinPolynomial { public var order: Int { return 4 } } -public struct BernsteinPolynomial5: BernsteinPolynomial { +public struct BernsteinPolynomial5: BernsteinPolynomial, Sendable { // func enumerated(block: (Int, CGFloat) -> Void) { // block(0, b0) // block(1, b1) diff --git a/BezierKit/Library/QuadraticCurve.swift b/BezierKit/Library/QuadraticCurve.swift index 5d0c2647..b0e2b222 100644 --- a/BezierKit/Library/QuadraticCurve.swift +++ b/BezierKit/Library/QuadraticCurve.swift @@ -11,7 +11,7 @@ import CoreGraphics #endif import Foundation -public struct QuadraticCurve: NonlinearBezierCurve, Equatable { +public struct QuadraticCurve: NonlinearBezierCurve, Equatable, Sendable { public var p0, p1, p2: CGPoint diff --git a/BezierKit/Library/Shape.swift b/BezierKit/Library/Shape.swift index d6701a88..30aa7ace 100644 --- a/BezierKit/Library/Shape.swift +++ b/BezierKit/Library/Shape.swift @@ -11,7 +11,7 @@ import CoreGraphics #endif import Foundation -public struct ShapeIntersection: Equatable { +public struct ShapeIntersection: Equatable, Sendable { let curve1: BezierCurve let curve2: BezierCurve let intersections: [Intersection] @@ -20,8 +20,8 @@ public struct ShapeIntersection: Equatable { } } -public struct Shape: Equatable { - public struct Cap: Equatable { +public struct Shape: Equatable, Sendable { + public struct Cap: Equatable, Sendable { let curve: BezierCurve let virtual: Bool // a cap is virtual if it is internal (not part of the outline of the boundary) init(curve: BezierCurve, virtual: Bool) { diff --git a/BezierKit/Library/Types.swift b/BezierKit/Library/Types.swift index addd07dd..8378e6c4 100644 --- a/BezierKit/Library/Types.swift +++ b/BezierKit/Library/Types.swift @@ -11,7 +11,7 @@ import CoreGraphics #endif import Foundation -public struct Intersection: Equatable, Comparable { +public struct Intersection: Equatable, Comparable, Sendable { public var t1: CGFloat public var t2: CGFloat public static func < (lhs: Intersection, rhs: Intersection ) -> Bool { @@ -25,7 +25,7 @@ public struct Intersection: Equatable, Comparable { } } -public struct Interval: Equatable { +public struct Interval: Equatable, Sendable { public var start: CGFloat public var end: CGFloat public init(start: CGFloat, end: CGFloat) { @@ -34,7 +34,7 @@ public struct Interval: Equatable { } } -public struct BoundingBox: Equatable { +public struct BoundingBox: Equatable, Sendable { public var min: CGPoint public var max: CGPoint public var cgRect: CGRect { diff --git a/BezierKit/Library/Utils.swift b/BezierKit/Library/Utils.swift index e680c6dd..9f98c633 100644 --- a/BezierKit/Library/Utils.swift +++ b/BezierKit/Library/Utils.swift @@ -116,7 +116,7 @@ internal class Utils { x: B.x + (B.x-C.x)/s, y: B.y + (B.y-C.y)/s ) - return ( A:A, B:B, C:C ) + return (A: A, B: B, C: C) } static func abcRatio(n: Int, t: CGFloat = 0.5) -> CGFloat { diff --git a/Package.swift b/Package.swift index 1ac483d3..24489613 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,7 @@ import PackageDescription let package = Package( name: "BezierKit", platforms: [ - .macOS(.v10_12), .iOS(.v10), + .macOS(.v10_12), .iOS(.v12), ], products: [ .library( From 110bc591f4443ea3e0c4d3bec817135ea16c2d98 Mon Sep 17 00:00:00 2001 From: hfutrell Date: Fri, 18 Oct 2024 15:38:19 -0700 Subject: [PATCH 02/12] strict concurrency checking. --- BezierKit/BezierKit.xcodeproj/project.pbxproj | 8 +++ BezierKit/BezierKitTests/LockTests.swift | 60 +++++++++++-------- BezierKit/Library/Draw.swift | 12 ++-- 3 files changed, 50 insertions(+), 30 deletions(-) diff --git a/BezierKit/BezierKit.xcodeproj/project.pbxproj b/BezierKit/BezierKit.xcodeproj/project.pbxproj index 6d29da77..8b04b351 100644 --- a/BezierKit/BezierKit.xcodeproj/project.pbxproj +++ b/BezierKit/BezierKit.xcodeproj/project.pbxproj @@ -1006,6 +1006,7 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SUPPORTS_MACCATALYST = NO; + SWIFT_STRICT_CONCURRENCY = complete; SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; @@ -1040,6 +1041,7 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SUPPORTS_MACCATALYST = NO; + SWIFT_STRICT_CONCURRENCY = complete; SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; @@ -1075,6 +1077,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.HolmesFutrell.BezierKit; PRODUCT_NAME = BezierKit; SKIP_INSTALL = YES; + SWIFT_STRICT_CONCURRENCY = complete; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1108,6 +1111,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.HolmesFutrell.BezierKit; PRODUCT_NAME = BezierKit; SKIP_INSTALL = YES; + SWIFT_STRICT_CONCURRENCY = complete; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1129,6 +1133,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.HolmesFutrell.BezierKit-iOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; + SWIFT_STRICT_CONCURRENCY = complete; SWIFT_VERSION = 5.0; }; name = Debug; @@ -1148,6 +1153,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.HolmesFutrell.BezierKit-iOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; + SWIFT_STRICT_CONCURRENCY = complete; SWIFT_VERSION = 5.0; VALIDATE_PRODUCT = YES; }; @@ -1168,6 +1174,7 @@ MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = "com.HolmesFutrell.BezierKit-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_STRICT_CONCURRENCY = complete; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 5.0; }; @@ -1188,6 +1195,7 @@ MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = "com.HolmesFutrell.BezierKit-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_STRICT_CONCURRENCY = complete; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 5.0; }; diff --git a/BezierKit/BezierKitTests/LockTests.swift b/BezierKit/BezierKitTests/LockTests.swift index 685e92f0..9bad534b 100644 --- a/BezierKit/BezierKitTests/LockTests.swift +++ b/BezierKit/BezierKitTests/LockTests.swift @@ -6,12 +6,26 @@ // Copyright © 2019 Holmes Futrell. All rights reserved. // -import XCTest +@preconcurrency import XCTest @testable import BezierKit #if !os(WASI) class LockTests: XCTestCase { - func testPathPropertyAtomicity() { + func testPathPropertyAtomicity() async { + + @MainActor class Results: Sendable { + #if canImport(CoreGraphics) + var cgPaths: [Int: CGPath] = [:] + func setPath(at index: Int, _ value: CGPath) { + cgPaths[index] = value + } + #endif + var boundingBoxes: [Int: BoundingBox] = [:] + func setBoundingBox(at index: Int, _ value: BoundingBox) { + boundingBoxes[index] = value + } + } + // ensure that lazy properties of Path are only initialized once let rect = CGRect(x: 0, y: 0, width: 1, height: 1) let path = Path(rect: rect) @@ -20,38 +34,36 @@ class LockTests: XCTestCase { let expectation = XCTestExpectation() expectation.expectedFulfillmentCount = threadCount - #if canImport(CoreGraphics) - var cgPaths: [Int: CGPath] = [:] - #endif - var boundingBoxes: [Int: BoundingBox] = [:] - + let results = await Results() for i in 0.. Date: Fri, 18 Oct 2024 15:54:08 -0700 Subject: [PATCH 03/12] should support iOS 12 again. --- BezierKit/BezierKitTests/LockTests.swift | 35 ++++++++++-------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/BezierKit/BezierKitTests/LockTests.swift b/BezierKit/BezierKitTests/LockTests.swift index 9bad534b..37f1ca75 100644 --- a/BezierKit/BezierKitTests/LockTests.swift +++ b/BezierKit/BezierKitTests/LockTests.swift @@ -11,19 +11,13 @@ #if !os(WASI) class LockTests: XCTestCase { - func testPathPropertyAtomicity() async { + @MainActor func testPathPropertyAtomicity() { @MainActor class Results: Sendable { #if canImport(CoreGraphics) var cgPaths: [Int: CGPath] = [:] - func setPath(at index: Int, _ value: CGPath) { - cgPaths[index] = value - } #endif var boundingBoxes: [Int: BoundingBox] = [:] - func setBoundingBox(at index: Int, _ value: BoundingBox) { - boundingBoxes[index] = value - } } // ensure that lazy properties of Path are only initialized once @@ -34,35 +28,36 @@ class LockTests: XCTestCase { let expectation = XCTestExpectation() expectation.expectedFulfillmentCount = threadCount - let results = await Results() + let results = Results() for i in 0.. Date: Fri, 18 Oct 2024 15:57:41 -0700 Subject: [PATCH 04/12] exclude Info.plist from swift tests. --- Package.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 24489613..8322d870 100644 --- a/Package.swift +++ b/Package.swift @@ -23,7 +23,10 @@ let package = Package( .testTarget( name: "BezierKitTests", dependencies: ["BezierKit"], - path: "BezierKit/BezierKitTests" + path: "BezierKit/BezierKitTests", + exclude: [ + "Info.plist" + ] ), ], swiftLanguageVersions: [.v5] From 406c3bc6810147070402d064f0280f1f133fd7fb Mon Sep 17 00:00:00 2001 From: hfutrell Date: Fri, 18 Oct 2024 16:06:07 -0700 Subject: [PATCH 05/12] bump target to iOS 13. --- BezierKit/BezierKit.xcodeproj/project.pbxproj | 4 +-- BezierKit/BezierKitTests/LockTests.swift | 25 +++++++++---------- Package.swift | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/BezierKit/BezierKit.xcodeproj/project.pbxproj b/BezierKit/BezierKit.xcodeproj/project.pbxproj index 8b04b351..00e6b645 100644 --- a/BezierKit/BezierKit.xcodeproj/project.pbxproj +++ b/BezierKit/BezierKit.xcodeproj/project.pbxproj @@ -871,7 +871,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MACOSX_DEPLOYMENT_TARGET = 10.12; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; @@ -930,7 +930,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MACOSX_DEPLOYMENT_TARGET = 10.12; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; diff --git a/BezierKit/BezierKitTests/LockTests.swift b/BezierKit/BezierKitTests/LockTests.swift index 37f1ca75..94a587e5 100644 --- a/BezierKit/BezierKitTests/LockTests.swift +++ b/BezierKit/BezierKitTests/LockTests.swift @@ -11,7 +11,7 @@ #if !os(WASI) class LockTests: XCTestCase { - @MainActor func testPathPropertyAtomicity() { + func testPathPropertyAtomicity() async { @MainActor class Results: Sendable { #if canImport(CoreGraphics) @@ -28,15 +28,15 @@ class LockTests: XCTestCase { let expectation = XCTestExpectation() expectation.expectedFulfillmentCount = threadCount - let results = Results() + let results = await Results() for i in 0.. Date: Fri, 18 Oct 2024 16:13:42 -0700 Subject: [PATCH 06/12] web warnings. --- BezierKit/Library/CubicCurve.swift | 3 ++- BezierKit/Library/LineSegment.swift | 3 ++- BezierKit/Library/QuadraticCurve.swift | 3 ++- BezierKit/Library/Types.swift | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/BezierKit/Library/CubicCurve.swift b/BezierKit/Library/CubicCurve.swift index ef5b46eb..ef5fd963 100644 --- a/BezierKit/Library/CubicCurve.swift +++ b/BezierKit/Library/CubicCurve.swift @@ -8,8 +8,9 @@ #if canImport(CoreGraphics) import CoreGraphics +#else +@preconcurrency import Foundation #endif -import Foundation /** Cubic Bézier Curve diff --git a/BezierKit/Library/LineSegment.swift b/BezierKit/Library/LineSegment.swift index c0c7f132..e60f093e 100644 --- a/BezierKit/Library/LineSegment.swift +++ b/BezierKit/Library/LineSegment.swift @@ -8,8 +8,9 @@ #if canImport(CoreGraphics) import CoreGraphics +#else +@preconcurrency import Foundation #endif -import Foundation public struct LineSegment: BezierCurve, Equatable, Sendable { diff --git a/BezierKit/Library/QuadraticCurve.swift b/BezierKit/Library/QuadraticCurve.swift index b0e2b222..7491524b 100644 --- a/BezierKit/Library/QuadraticCurve.swift +++ b/BezierKit/Library/QuadraticCurve.swift @@ -8,8 +8,9 @@ #if canImport(CoreGraphics) import CoreGraphics +#else +@preconcurrency import Foundation #endif -import Foundation public struct QuadraticCurve: NonlinearBezierCurve, Equatable, Sendable { diff --git a/BezierKit/Library/Types.swift b/BezierKit/Library/Types.swift index 8378e6c4..ac03d2b3 100644 --- a/BezierKit/Library/Types.swift +++ b/BezierKit/Library/Types.swift @@ -8,8 +8,9 @@ #if canImport(CoreGraphics) import CoreGraphics +#else +@preconcurrency import Foundation #endif -import Foundation public struct Intersection: Equatable, Comparable, Sendable { public var t1: CGFloat From 099bb1ce782527baeb913a5ac1ee58e25010f65f Mon Sep 17 00:00:00 2001 From: hfutrell Date: Fri, 18 Oct 2024 16:15:58 -0700 Subject: [PATCH 07/12] web warnings. --- BezierKit/BezierKitTests/LockTests.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/BezierKit/BezierKitTests/LockTests.swift b/BezierKit/BezierKitTests/LockTests.swift index 94a587e5..1e5e2048 100644 --- a/BezierKit/BezierKitTests/LockTests.swift +++ b/BezierKit/BezierKitTests/LockTests.swift @@ -6,7 +6,12 @@ // Copyright © 2019 Holmes Futrell. All rights reserved. // +#if os(WASI) +import XCTest +#else @preconcurrency import XCTest +#endif + @testable import BezierKit #if !os(WASI) From 725d79ba01e751d9afd02eddcc4ba9e1d4295cd1 Mon Sep 17 00:00:00 2001 From: hfutrell Date: Mon, 21 Oct 2024 16:02:10 -0700 Subject: [PATCH 08/12] fix case of single cubic curve closed path including unit test. --- BezierKit/BezierKitTests/Path+VectorBooleanTests.swift | 10 ++++++++++ BezierKit/Library/PathComponent.swift | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/BezierKit/BezierKitTests/Path+VectorBooleanTests.swift b/BezierKit/BezierKitTests/Path+VectorBooleanTests.swift index 15fe9378..48e7e74a 100644 --- a/BezierKit/BezierKitTests/Path+VectorBooleanTests.swift +++ b/BezierKit/BezierKitTests/Path+VectorBooleanTests.swift @@ -477,6 +477,16 @@ class PathVectorBooleanTests: XCTestCase { XCTAssertTrue(componentsEqualAsideFromElementOrdering(result.components[0], square.components[0])) } + func testCrossingsRemovedSingleCurveLoop() { + let cgPath = CGMutablePath() + cgPath.move(to: CGPoint(x: 0, y: 0)) + cgPath.addCurve(to: CGPoint(x: 0, y: 0), + control1: CGPoint(x: -1, y: 1), + control2: CGPoint(x: 1, y: 1)) + let path = Path(cgPath: cgPath) + XCTAssertEqual(path.crossingsRemoved(), path) + } + func testCrossingsRemovedEdgeCase() { // this is an edge cases which caused difficulty in practice // the contour, which intersects at (1,1) creates two squares, one with -1 winding count diff --git a/BezierKit/Library/PathComponent.swift b/BezierKit/Library/PathComponent.swift index 74fbe65d..3ff51495 100644 --- a/BezierKit/Library/PathComponent.swift +++ b/BezierKit/Library/PathComponent.swift @@ -371,7 +371,10 @@ open class PathComponent: NSObject, Reversible, Transformable, @unchecked Sendab if i1 == i2 { // we are intersecting a path element against itself (only possible with cubic or higher order) if self.order(at: i1) == 3 { - elementIntersections = self.cubic(at: i1).selfIntersections + elementIntersections = self.cubic(at: i1).selfIntersections.filter { + guard self.numberOfElements == 1 else { return true } + return $0.t1 != 0 || $0.t2 != 1 // exclude intersection of single curve path closing itself + } } } else if i1 < i2 { // we are intersecting two distinct path elements From 718197c889a211712edd8ddcb147dbc3ce74b050 Mon Sep 17 00:00:00 2001 From: Holmes Futrell Date: Mon, 21 Oct 2024 16:20:04 -0700 Subject: [PATCH 09/12] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 698401d4..7f1aa936 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ To integrate BezierKit into your Xcode project using CocoaPods, add it to your t ```ruby target '' do - pod 'BezierKit', '>= 0.15.0' + pod 'BezierKit', '>= 0.16.0' end ``` @@ -66,7 +66,7 @@ import PackageDescription let package = Package( name: "", dependencies: [ - .package(url: "https://github.com/hfutrell/BezierKit.git", from: "0.15.0"), + .package(url: "https://github.com/hfutrell/BezierKit.git", from: "0.16.0"), ] ) ``` @@ -96,7 +96,7 @@ let curve = CubicCurve( ### Intersecting Curves -The `intersections(with curve: BezierCurve) -> [Intersection]` method determines each intersection between `self` and `curve` as an array of `Intersection` objects. Each intersection has two fields: `t1` represents the t-value for `self` at the intersection while `t2` represents the t-value for `curve` at the intersection. You can use the `ponit(at:)` method on either of the curves to calculate the coordinates of the intersection by passing in the corresponding t-value for the curve. +The `intersections(with curve: BezierCurve) -> [Intersection]` method determines each intersection between `self` and `curve` as an array of `Intersection` objects. Each intersection has two fields: `t1` represents the t-value for `self` at the intersection while `t2` represents the t-value for `curve` at the intersection. You can use the `point(at:)` method on either of the curves to calculate the coordinates of the intersection by passing in the corresponding t-value for the curve. Cubic curves may self-intersect which can be determined by calling the `selfIntersections()` method. From 03d2f8835d60ba3d9eac540a0699a8f62779c606 Mon Sep 17 00:00:00 2001 From: hfutrell Date: Mon, 21 Oct 2024 16:33:23 -0700 Subject: [PATCH 10/12] iOS deployment target to 13. --- BezierKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BezierKit.podspec b/BezierKit.podspec index f2a767b3..53308b77 100644 --- a/BezierKit.podspec +++ b/BezierKit.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.author = { "Holmes Futrell" => "holmesfutrell@gmail.com" } s.swift_version = "5.3" - s.ios.deployment_target = "12.0" + s.ios.deployment_target = "13.0" s.osx.deployment_target = "10.12" s.ios.framework = 'UIKit', 'CoreGraphics' s.osx.framework = 'AppKit' From e7fca10652be16e08ee2b6ec54e295526a3ec5dd Mon Sep 17 00:00:00 2001 From: Holmes Futrell Date: Mon, 21 Oct 2024 17:10:34 -0700 Subject: [PATCH 11/12] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7f1aa936..627d73fb 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ To integrate BezierKit into your Xcode project using CocoaPods, add it to your t ```ruby target '' do - pod 'BezierKit', '>= 0.16.0' + pod 'BezierKit', '>= 0.16.1' end ``` @@ -66,7 +66,7 @@ import PackageDescription let package = Package( name: "", dependencies: [ - .package(url: "https://github.com/hfutrell/BezierKit.git", from: "0.16.0"), + .package(url: "https://github.com/hfutrell/BezierKit.git", from: "0.16.1"), ] ) ``` From c730310afe374686377fe6046a14e2be10eabd07 Mon Sep 17 00:00:00 2001 From: Holmes Futrell Date: Mon, 21 Oct 2024 17:10:58 -0700 Subject: [PATCH 12/12] Update BezierKit.podspec --- BezierKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BezierKit.podspec b/BezierKit.podspec index 53308b77..91c929a4 100644 --- a/BezierKit.podspec +++ b/BezierKit.podspec @@ -5,7 +5,7 @@ Pod::Spec.new do |s| s.name = "BezierKit" - s.version = "0.16.0" + s.version = "0.16.1" s.summary = "comprehensive Bezier Path library written in Swift" s.homepage = "https://github.com/hfutrell/BezierKit" s.license = "MIT"