From 7042102108a0c260d18c2869a3c8fa0d602c9a99 Mon Sep 17 00:00:00 2001 From: Shibo Lyu Date: Wed, 18 Dec 2024 16:49:24 +0800 Subject: [PATCH 1/3] fix: build on non-macOS. --- Sources/CropImage/CropImageView.swift | 2 +- Sources/CropImage/PlatformImage.swift | 7 +++++++ Sources/CropImage/UnderlyingImageView.swift | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Sources/CropImage/CropImageView.swift b/Sources/CropImage/CropImageView.swift index 4bed6f2..9cd2389 100644 --- a/Sources/CropImage/CropImageView.swift +++ b/Sources/CropImage/CropImageView.swift @@ -233,7 +233,7 @@ public struct CropImageView: View { var body: some View { VStack { CropImageView( - image: .init(contentsOf: URL(string: "file:///System/Library/Desktop%20Pictures/Hello%20Metallic%20Blue.heic")!)!, + image: .previewImage, targetSize: targetSize ) { result = $0 diff --git a/Sources/CropImage/PlatformImage.swift b/Sources/CropImage/PlatformImage.swift index 831e93b..7963809 100644 --- a/Sources/CropImage/PlatformImage.swift +++ b/Sources/CropImage/PlatformImage.swift @@ -13,10 +13,17 @@ import AppKit /// /// On macOS, it's `NSImage` and on iOS/visionOS it's `UIImage`. public typealias PlatformImage = NSImage +extension PlatformImage { + static let previewImage: PlatformImage = .init(contentsOf: URL(string: "file:///System/Library/Desktop%20Pictures/Hello%20Metallic%20Blue.heic")!)! +} #else import UIKit /// The image object type, aliased to each platform. /// /// On macOS, it's `NSImage` and on iOS/visionOS it's `UIImage`. public typealias PlatformImage = UIImage +extension PlatformImage { + // This doesn't really work, but at least passes build. + static let previewImage: PlatformImage = .init(contentsOfFile: "/System/Library/Desktop Pictures/Hello Metallic Blue.heic")! +} #endif diff --git a/Sources/CropImage/UnderlyingImageView.swift b/Sources/CropImage/UnderlyingImageView.swift index 9d1ee3b..882ade4 100644 --- a/Sources/CropImage/UnderlyingImageView.swift +++ b/Sources/CropImage/UnderlyingImageView.swift @@ -202,7 +202,7 @@ struct UnderlyingImageView: View { offset: $offset, scale: $scale, rotation: $rotation, - image: .init(contentsOf: URL(string: "file:///System/Library/Desktop%20Pictures/Hello%20Metallic%20Blue.heic")!)!, + image: .previewImage, viewSize: .init(width: 200, height: 100), targetSize: .init(width: 100, height: 100), fulfillTargetFrame: true From 481f59cf412f41641d4b737d8fbb51433031ce03 Mon Sep 17 00:00:00 2001 From: Shibo Lyu Date: Fri, 20 Dec 2024 14:54:32 +0800 Subject: [PATCH 2/3] fix: macos build fixes #4 --- Sources/CropImage/PlatformImage.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/CropImage/PlatformImage.swift b/Sources/CropImage/PlatformImage.swift index 7963809..ab243b5 100644 --- a/Sources/CropImage/PlatformImage.swift +++ b/Sources/CropImage/PlatformImage.swift @@ -14,7 +14,7 @@ import AppKit /// On macOS, it's `NSImage` and on iOS/visionOS it's `UIImage`. public typealias PlatformImage = NSImage extension PlatformImage { - static let previewImage: PlatformImage = .init(contentsOf: URL(string: "file:///System/Library/Desktop%20Pictures/Hello%20Metallic%20Blue.heic")!)! + @MainActor static let previewImage: PlatformImage = .init(contentsOf: URL(string: "file:///System/Library/Desktop%20Pictures/Hello%20Metallic%20Blue.heic")!)! } #else import UIKit From 9a8b486f5529768600a885d3e53cde19867a7098 Mon Sep 17 00:00:00 2001 From: Shibo Lyu Date: Tue, 24 Dec 2024 14:18:08 +0800 Subject: [PATCH 3/3] Create FUNDING.yml --- .github/FUNDING.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..b1de7a2 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: [laosb] +buy_me_a_coffee: laosb