diff --git a/MiniBlocks.swiftpm/Sources/Utils/CompatibilityLayer.swift b/MiniBlocks.swiftpm/Sources/Utils/CompatibilityLayer.swift index 703f72a..63da82f 100644 --- a/MiniBlocks.swiftpm/Sources/Utils/CompatibilityLayer.swift +++ b/MiniBlocks.swiftpm/Sources/Utils/CompatibilityLayer.swift @@ -6,7 +6,7 @@ import CoreGraphics /// and UIKit share many similarities, making it easy to abstract over the (few) /// differences. -#if canImport(AppKit) +#if canImport(AppKit) && !targetEnvironment(macCatalyst) import AppKit diff --git a/MiniBlocks.swiftpm/Sources/View/MiniBlocksSceneView.swift b/MiniBlocks.swiftpm/Sources/View/MiniBlocksSceneView.swift index bcb194f..dfac57a 100644 --- a/MiniBlocks.swiftpm/Sources/View/MiniBlocksSceneView.swift +++ b/MiniBlocks.swiftpm/Sources/View/MiniBlocksSceneView.swift @@ -2,7 +2,7 @@ import SceneKit /// A SceneKit view that fixes key handling when an overlayed SpriteKit scene is present. See https://developer.apple.com/library/archive/samplecode/Badger/Listings/Common_View_swift.html class MiniBlocksSceneView: SCNView { - #if canImport(AppKit) + #if canImport(AppKit) && !targetEnvironment(macCatalyst) weak var keyEventsDelegate: NSResponder? override func keyDown(with event: NSEvent) { diff --git a/MiniBlocks.swiftpm/Sources/View/MiniBlocksViewController.swift b/MiniBlocks.swiftpm/Sources/View/MiniBlocksViewController.swift index 8f124a7..10f0493 100644 --- a/MiniBlocks.swiftpm/Sources/View/MiniBlocksViewController.swift +++ b/MiniBlocks.swiftpm/Sources/View/MiniBlocksViewController.swift @@ -29,7 +29,7 @@ public final class MiniBlocksViewController: ViewController, SCNSceneRendererDel private let sceneFrame: CGRect? private var inputSensivity: SceneFloat = 1 - #if canImport(AppKit) + #if canImport(AppKit) && !targetEnvironment(macCatalyst) @Box private var usesMouseKeyboardControls = true private var receivedFirstMouseEvent: Bool = false private var mouseCaptured: Bool = false { @@ -157,7 +157,7 @@ public final class MiniBlocksViewController: ViewController, SCNSceneRendererDel add(entity: makeAchievementHUDEntity(in: overlayScene.frame, playerEntity: playerEntity, usesMouseKeyboardControls: _usesMouseKeyboardControls)) } - #if canImport(AppKit) + #if canImport(AppKit) && !targetEnvironment(macCatalyst) add(entity: makePauseHUDEntity(in: overlayScene.frame)) #endif @@ -175,7 +175,7 @@ public final class MiniBlocksViewController: ViewController, SCNSceneRendererDel // Keep scene active, otherwise it will stop sending renderer(_:updateAtTime:)s when nothing changes. See also https://stackoverflow.com/questions/39336509/how-do-you-set-up-a-game-loop-for-scenekit sceneView.isPlaying = true - #if canImport(AppKit) + #if canImport(AppKit) && !targetEnvironment(macCatalyst) // Set up mouse/keyboard handling when using AppKit (on macOS) sceneView.keyEventsDelegate = self @@ -260,7 +260,7 @@ public final class MiniBlocksViewController: ViewController, SCNSceneRendererDel } } - #if canImport(AppKit) + #if canImport(AppKit) && !targetEnvironment(macCatalyst) // Provide initial update to mouse capture visibility component if let component = entity.component(ofType: MouseCaptureVisibilityComponent.self) { component.update(mouseCaptured: mouseCaptured) @@ -450,7 +450,7 @@ public final class MiniBlocksViewController: ViewController, SCNSceneRendererDel // MARK: AppKit-based mouse/keyboard controls - #if canImport(AppKit) + #if canImport(AppKit) && !targetEnvironment(macCatalyst) public override func keyDown(with event: NSEvent) { guard !event.isARepeat else { return }