From 879aef8d6b209f9600d76c403b43a01838e38e63 Mon Sep 17 00:00:00 2001 From: Max Cobb Date: Tue, 9 Nov 2021 08:53:42 -0800 Subject: [PATCH 1/5] added realityfoundation import, if can import --- Sources/FocusEntity/FocusEntity.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/FocusEntity/FocusEntity.swift b/Sources/FocusEntity/FocusEntity.swift index 60f71cc..703fc09 100644 --- a/Sources/FocusEntity/FocusEntity.swift +++ b/Sources/FocusEntity/FocusEntity.swift @@ -8,6 +8,9 @@ #if canImport(ARKit) import RealityKit +#if canImport(RealityFoundation) +import RealityFoundation +#endif import ARKit import Combine From b906f97badc5813d383a0bd461690c0c8c335055 Mon Sep 17 00:00:00 2001 From: laurent brusa Date: Fri, 19 Nov 2021 17:50:31 +0100 Subject: [PATCH 2/5] simulatorfix --- Sources/FocusEntity/FocusEntityComponent.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/FocusEntity/FocusEntityComponent.swift b/Sources/FocusEntity/FocusEntityComponent.swift index b69d920..ac468fc 100644 --- a/Sources/FocusEntity/FocusEntityComponent.swift +++ b/Sources/FocusEntity/FocusEntityComponent.swift @@ -6,7 +6,7 @@ // Copyright © 2019 Max Cobb. All rights reserved. // -#if canImport(ARKit) +#if canImport(ARKit) && !targetEnvironment(simulator) import RealityKit import ARKit From 81b33761f5c235293d2b2e5aaacbe264dbeec79d Mon Sep 17 00:00:00 2001 From: laurent brusa Date: Fri, 19 Nov 2021 17:51:39 +0100 Subject: [PATCH 3/5] simulator fix --- Sources/FocusEntity/FocusEntity+Alignment.swift | 2 +- Sources/FocusEntity/FocusEntity+Classic.swift | 2 +- Sources/FocusEntity/FocusEntity+Colored.swift | 2 +- Sources/FocusEntity/FocusEntity+Segment.swift | 2 +- Sources/FocusEntity/FocusEntity.swift | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/FocusEntity/FocusEntity+Alignment.swift b/Sources/FocusEntity/FocusEntity+Alignment.swift index cd628fd..32173d5 100644 --- a/Sources/FocusEntity/FocusEntity+Alignment.swift +++ b/Sources/FocusEntity/FocusEntity+Alignment.swift @@ -6,7 +6,7 @@ // Copyright © 2019 Max Cobb. All rights reserved. // -#if canImport(ARKit) +#if canImport(ARKit) && !targetEnvironment(simulator) import RealityKit import ARKit import Combine diff --git a/Sources/FocusEntity/FocusEntity+Classic.swift b/Sources/FocusEntity/FocusEntity+Classic.swift index 1f2e01b..35bbb90 100644 --- a/Sources/FocusEntity/FocusEntity+Classic.swift +++ b/Sources/FocusEntity/FocusEntity+Classic.swift @@ -6,7 +6,7 @@ // Copyright © 2019 Max Cobb. All rights reserved. // -#if canImport(ARKit) +#if canImport(ARKit) && !targetEnvironment(simulator) import RealityKit /// An extension of FocusEntity holding the methods for the "classic" style. diff --git a/Sources/FocusEntity/FocusEntity+Colored.swift b/Sources/FocusEntity/FocusEntity+Colored.swift index b4b4ea7..322587b 100644 --- a/Sources/FocusEntity/FocusEntity+Colored.swift +++ b/Sources/FocusEntity/FocusEntity+Colored.swift @@ -6,7 +6,7 @@ // Copyright © 2019 Max Cobb. All rights reserved. // -#if canImport(ARKit) +#if canImport(ARKit) && !targetEnvironment(simulator) import RealityKit /// An extension of FocusEntity holding the methods for the "colored" style. diff --git a/Sources/FocusEntity/FocusEntity+Segment.swift b/Sources/FocusEntity/FocusEntity+Segment.swift index a186563..e1c90f3 100644 --- a/Sources/FocusEntity/FocusEntity+Segment.swift +++ b/Sources/FocusEntity/FocusEntity+Segment.swift @@ -6,7 +6,7 @@ // Copyright © 2019 Max Cobb. All rights reserved. // -#if canImport(ARKit) +#if canImport(ARKit) && !targetEnvironment(simulator) import RealityKit internal extension FocusEntity { diff --git a/Sources/FocusEntity/FocusEntity.swift b/Sources/FocusEntity/FocusEntity.swift index 703fc09..f91e0e3 100644 --- a/Sources/FocusEntity/FocusEntity.swift +++ b/Sources/FocusEntity/FocusEntity.swift @@ -6,7 +6,7 @@ // Copyright © 2019 Max Cobb. All rights reserved. // -#if canImport(ARKit) +#if canImport(ARKit) && !targetEnvironment(simulator) import RealityKit #if canImport(RealityFoundation) import RealityFoundation From 3a7e4db25e6d0127bc8a50b59a669076911f962c Mon Sep 17 00:00:00 2001 From: Max Cobb Date: Fri, 19 Nov 2021 15:24:46 -0800 Subject: [PATCH 4/5] removed some \'if simulator\' statements, added initialisers so that simulator will compile with same code as device --- Sources/FocusEntity/FocusEntity+Segment.swift | 2 -- Sources/FocusEntity/FocusEntity.swift | 14 ++++++++++---- Sources/FocusEntity/FocusEntityComponent.swift | 2 -- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Sources/FocusEntity/FocusEntity+Segment.swift b/Sources/FocusEntity/FocusEntity+Segment.swift index e1c90f3..2f59e45 100644 --- a/Sources/FocusEntity/FocusEntity+Segment.swift +++ b/Sources/FocusEntity/FocusEntity+Segment.swift @@ -6,7 +6,6 @@ // Copyright © 2019 Max Cobb. All rights reserved. // -#if canImport(ARKit) && !targetEnvironment(simulator) import RealityKit internal extension FocusEntity { @@ -154,4 +153,3 @@ internal extension FocusEntity { } } -#endif diff --git a/Sources/FocusEntity/FocusEntity.swift b/Sources/FocusEntity/FocusEntity.swift index f91e0e3..3fbb702 100644 --- a/Sources/FocusEntity/FocusEntity.swift +++ b/Sources/FocusEntity/FocusEntity.swift @@ -6,11 +6,12 @@ // Copyright © 2019 Max Cobb. All rights reserved. // -#if canImport(ARKit) && !targetEnvironment(simulator) import RealityKit #if canImport(RealityFoundation) import RealityFoundation #endif + +#if canImport(ARKit) && !targetEnvironment(simulator) import ARKit import Combine @@ -330,9 +331,14 @@ open class FocusEntity: Entity, HasAnchoring, HasFocusEntity { FocusEntity is only enabled for environments which can import ARKit. */ open class FocusEntity { - init?() { - print("This is not supported when ARKit cannot be imported.") - return nil + public convenience init(on arView: ARView, style: FocusEntityComponent.Style) { + self.init(on: arView, focus: FocusEntityComponent(style: style)) + } + public convenience init(on arView: ARView, focus: FocusEntityComponent) { + self.init() + } + internal init() { + print("This is not supported when ARKit cannot be imported or using the simulator.") } } #endif diff --git a/Sources/FocusEntity/FocusEntityComponent.swift b/Sources/FocusEntity/FocusEntityComponent.swift index ac468fc..770d3c9 100644 --- a/Sources/FocusEntity/FocusEntityComponent.swift +++ b/Sources/FocusEntity/FocusEntityComponent.swift @@ -6,7 +6,6 @@ // Copyright © 2019 Max Cobb. All rights reserved. // -#if canImport(ARKit) && !targetEnvironment(simulator) import RealityKit import ARKit @@ -86,4 +85,3 @@ public struct FocusEntityComponent: Component { } } } -#endif From b330ab63042f04b47c865f1b6dbae94a0682a0b2 Mon Sep 17 00:00:00 2001 From: Max Cobb Date: Thu, 25 Nov 2021 11:02:13 -0800 Subject: [PATCH 5/5] update example to use package rather than just files from package --- .../project.pbxproj | 59 ++++++++----------- .../FocusEntity-Example/FocusARView.swift | 2 +- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/FocusEntity-Example/FocusEntity-Example.xcodeproj/project.pbxproj b/FocusEntity-Example/FocusEntity-Example.xcodeproj/project.pbxproj index e17b712..bc6a1cb 100644 --- a/FocusEntity-Example/FocusEntity-Example.xcodeproj/project.pbxproj +++ b/FocusEntity-Example/FocusEntity-Example.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 52; objects = { /* Begin PBXBuildFile section */ @@ -13,13 +13,7 @@ F301E0DA231462AB0028AAF1 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F301E0D9231462AB0028AAF1 /* Preview Assets.xcassets */; }; F301E0DD231462AB0028AAF1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F301E0DB231462AB0028AAF1 /* LaunchScreen.storyboard */; }; F301E0E5231462D90028AAF1 /* FocusARView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F301E0E4231462D90028AAF1 /* FocusARView.swift */; }; - F3D758E424992EAC0019A821 /* FocusEntity+Alignment.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3D758E324992EAC0019A821 /* FocusEntity+Alignment.swift */; }; - F3D758E6249930080019A821 /* FocusEntityComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3D758E5249930080019A821 /* FocusEntityComponent.swift */; }; - F3F29EE02317C0DA00C3864B /* FocusEntity+Classic.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3F29EDB2317C0DA00C3864B /* FocusEntity+Classic.swift */; }; - F3F29EE12317C0DA00C3864B /* FocusEntity+Segment.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3F29EDC2317C0DA00C3864B /* FocusEntity+Segment.swift */; }; - F3F29EE22317C0DA00C3864B /* float4x4+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3F29EDD2317C0DA00C3864B /* float4x4+Extension.swift */; }; - F3F29EE32317C0DA00C3864B /* FocusEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3F29EDE2317C0DA00C3864B /* FocusEntity.swift */; }; - F3F29EE42317C0DA00C3864B /* FocusEntity+Colored.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3F29EDF2317C0DA00C3864B /* FocusEntity+Colored.swift */; }; + F339DB65275013C700D9A2B2 /* FocusEntity in Frameworks */ = {isa = PBXBuildFile; productRef = F339DB64275013C700D9A2B2 /* FocusEntity */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -31,13 +25,7 @@ F301E0DC231462AB0028AAF1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; F301E0DE231462AB0028AAF1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; F301E0E4231462D90028AAF1 /* FocusARView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FocusARView.swift; sourceTree = ""; }; - F3D758E324992EAC0019A821 /* FocusEntity+Alignment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FocusEntity+Alignment.swift"; sourceTree = ""; }; - F3D758E5249930080019A821 /* FocusEntityComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FocusEntityComponent.swift; sourceTree = ""; }; - F3F29EDB2317C0DA00C3864B /* FocusEntity+Classic.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FocusEntity+Classic.swift"; sourceTree = ""; }; - F3F29EDC2317C0DA00C3864B /* FocusEntity+Segment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FocusEntity+Segment.swift"; sourceTree = ""; }; - F3F29EDD2317C0DA00C3864B /* float4x4+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "float4x4+Extension.swift"; path = "../../Sources/FocusEntity/float4x4+Extension.swift"; sourceTree = ""; }; - F3F29EDE2317C0DA00C3864B /* FocusEntity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FocusEntity.swift; path = ../../Sources/FocusEntity/FocusEntity.swift; sourceTree = ""; }; - F3F29EDF2317C0DA00C3864B /* FocusEntity+Colored.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FocusEntity+Colored.swift"; sourceTree = ""; }; + F339DB622750138A00D9A2B2 /* FocusEntity */ = {isa = PBXFileReference; lastKnownFileType = folder; name = FocusEntity; path = ..; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -45,6 +33,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F339DB65275013C700D9A2B2 /* FocusEntity in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -54,8 +43,10 @@ F301E0C4231462A90028AAF1 = { isa = PBXGroup; children = ( + F339DB612750138A00D9A2B2 /* Packages */, F301E0CF231462A90028AAF1 /* FocusEntity-Example */, F301E0CE231462A90028AAF1 /* Products */, + F339DB63275013C700D9A2B2 /* Frameworks */, ); sourceTree = ""; }; @@ -76,7 +67,6 @@ F301E0D6231462AB0028AAF1 /* Assets.xcassets */, F301E0DB231462AB0028AAF1 /* LaunchScreen.storyboard */, F301E0DE231462AB0028AAF1 /* Info.plist */, - F301E0EE231515370028AAF1 /* FocusEntity */, F301E0D8231462AB0028AAF1 /* Preview Content */, ); path = "FocusEntity-Example"; @@ -90,20 +80,20 @@ path = "Preview Content"; sourceTree = ""; }; - F301E0EE231515370028AAF1 /* FocusEntity */ = { + F339DB612750138A00D9A2B2 /* Packages */ = { isa = PBXGroup; children = ( - F3F29EDF2317C0DA00C3864B /* FocusEntity+Colored.swift */, - F3F29EDB2317C0DA00C3864B /* FocusEntity+Classic.swift */, - F3F29EDC2317C0DA00C3864B /* FocusEntity+Segment.swift */, - F3D758E5249930080019A821 /* FocusEntityComponent.swift */, - F3F29EDD2317C0DA00C3864B /* float4x4+Extension.swift */, - F3F29EDE2317C0DA00C3864B /* FocusEntity.swift */, - F3D758E324992EAC0019A821 /* FocusEntity+Alignment.swift */, + F339DB622750138A00D9A2B2 /* FocusEntity */, ); - name = FocusEntity; - path = ../Sources/FocusEntity; - sourceTree = SOURCE_ROOT; + name = Packages; + sourceTree = ""; + }; + F339DB63275013C700D9A2B2 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; }; /* End PBXGroup section */ @@ -122,6 +112,7 @@ ); name = "FocusEntity-Example"; packageProductDependencies = ( + F339DB64275013C700D9A2B2 /* FocusEntity */, ); productName = "FocusEntity-Example"; productReference = F301E0CD231462A90028AAF1 /* FocusEntity-Example.app */; @@ -180,16 +171,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - F3D758E424992EAC0019A821 /* FocusEntity+Alignment.swift in Sources */, - F3F29EE32317C0DA00C3864B /* FocusEntity.swift in Sources */, F301E0D3231462A90028AAF1 /* ContentView.swift in Sources */, - F3F29EE02317C0DA00C3864B /* FocusEntity+Classic.swift in Sources */, - F3F29EE42317C0DA00C3864B /* FocusEntity+Colored.swift in Sources */, F301E0D1231462A90028AAF1 /* AppDelegate.swift in Sources */, - F3F29EE22317C0DA00C3864B /* float4x4+Extension.swift in Sources */, - F3F29EE12317C0DA00C3864B /* FocusEntity+Segment.swift in Sources */, F301E0E5231462D90028AAF1 /* FocusARView.swift in Sources */, - F3D758E6249930080019A821 /* FocusEntityComponent.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -381,6 +365,13 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCSwiftPackageProductDependency section */ + F339DB64275013C700D9A2B2 /* FocusEntity */ = { + isa = XCSwiftPackageProductDependency; + productName = FocusEntity; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = F301E0C5231462A90028AAF1 /* Project object */; } diff --git a/FocusEntity-Example/FocusEntity-Example/FocusARView.swift b/FocusEntity-Example/FocusEntity-Example/FocusARView.swift index 4c345e9..4c0cd5e 100644 --- a/FocusEntity-Example/FocusEntity-Example/FocusARView.swift +++ b/FocusEntity-Example/FocusEntity-Example/FocusARView.swift @@ -7,7 +7,7 @@ // import RealityKit -// import FocusEntity +import FocusEntity import Combine import ARKit