Skip to content

Commit

Permalink
allow macos build for cross platform apps, but added warning when bui…
Browse files Browse the repository at this point in the history
…lding for simulator or macOS
  • Loading branch information
maxxfrazer committed Feb 27, 2022
1 parent a2e0c1e commit 28bfdd5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// swift-tools-version:5.0
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "FocusEntity",
platforms: [.iOS("13.0")],
platforms: [.iOS(.v13), .macOS(.v10_15)],
products: [
.library(name: "FocusEntity", targets: ["FocusEntity"])
],
Expand Down
6 changes: 5 additions & 1 deletion Sources/FocusEntity/FocusEntity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import RealityKit
import RealityFoundation
#endif

#if os(macOS) || targetEnvironment(simulator)
#warning("FocusEntity: This package is only fully available with physical iOS devices")
#endif

#if canImport(ARKit) && !targetEnvironment(simulator)
import ARKit
import Combine
Expand Down Expand Up @@ -338,7 +342,7 @@ open class FocusEntity {
self.init()
}
internal init() {
print("This is not supported when ARKit cannot be imported or using the simulator.")
print("This is only supported on a physical iOS device.")
}
}
#endif
6 changes: 6 additions & 0 deletions Sources/FocusEntity/FocusEntityComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
//

import RealityKit
#if !os(macOS)
import ARKit
#endif

internal struct ClassicStyle {
var color: Material.Color
Expand Down Expand Up @@ -69,7 +71,9 @@ public struct FocusEntityComponent: Component {
)
internal var isOpen = true
internal var segments: [FocusEntity.Segment] = []
#if !os(macOS)
public var allowedRaycast: ARRaycastQuery.Target = .estimatedPlane
#endif

static var defaultPlane = MeshResource.generatePlane(
width: 0.1, depth: 0.1
Expand All @@ -79,9 +83,11 @@ public struct FocusEntityComponent: Component {
self.style = style
// If the device has LiDAR, then default behaviour is to only allow
// existing detected planes
#if !os(macOS)
if #available(iOS 13.4, *),
ARWorldTrackingConfiguration.supportsSceneReconstruction(.mesh) {
self.allowedRaycast = .existingPlaneGeometry
}
#endif
}
}

0 comments on commit 28bfdd5

Please sign in to comment.