Skip to content

Commit

Permalink
Make conditional compilation scoped more tightly
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Mar 29, 2024
1 parent 783dce5 commit 7a96db5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Sources/NSUI/Image.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import SwiftUI

extension Image {
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
public init(nsuiImage: NSUIImage) {
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
self.init(nsImage: nsuiImage)
}
#elseif canImport(UIKit)
public init(nsuiImage: NSUIImage) {
self.init(uiImage: nsuiImage)
}
#endif
}
}

@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
Expand Down
11 changes: 11 additions & 0 deletions Tests/NSUITests/ImageTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import SwiftUI
import XCTest

import NSUI

final class ImageTests: XCTestCase {
func testInit() {
let _ = Image(nsuiImage: NSUIImage())
}
}

0 comments on commit 7a96db5

Please sign in to comment.