Skip to content

Commit

Permalink
Fix Catalyst build by updating cond-compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Sep 17, 2024
1 parent b4db3ba commit 76ab35a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion MiniBlocks.swiftpm/Sources/Utils/CompatibilityLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion MiniBlocks.swiftpm/Sources/View/MiniBlocksSceneView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions MiniBlocks.swiftpm/Sources/View/MiniBlocksViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 }
Expand Down

0 comments on commit 76ab35a

Please sign in to comment.