Skip to content

Commit

Permalink
fix: build on non-macOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
laosb committed Dec 18, 2024
1 parent a9672b8 commit 7042102
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/CropImage/CropImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public struct CropImageView<Controls: View, CutHole: View>: 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
Expand Down
7 changes: 7 additions & 0 deletions Sources/CropImage/PlatformImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Sources/CropImage/UnderlyingImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7042102

Please sign in to comment.