Demo code not compiling…

Loved the session, wanted to try out the demo code and then work through understanding it. 25 build errors that appear to be swift syntax related… is that just recent code changes or is there an easy fix?

Can you provide some of the build errors?

Sure, starting from the top:

  • Incorrect argument label in call (have ':types:', expected ':with😂 FoodPool.swift
  • Type 'UIEvent?' has no member 'featurePoint' FoodPool.swift
  • Type of expression is ambiguous without more context FoodPool.swift
  • Cannot find 'SceneUnderstandingComponent' in scope Scattering.swift (also in Fish.swift, Character.swift)
  • Extra arguments at positions @2, @3 in call Character.swift ! 'init(_😃 declared here
  • Type 'AnchoringComponent.Target' has no member 'horizontal'
  • ....

The mix and number seem to suggest that either something is missing in the downloaded code OR the version of Xcode is wrong (using 13.0 beta (12A5154h)).

Hi @GilW and @kcrao1, I see the build errors that you are encountering. I will open a bug report about this, hopefully we can resolve this issue.

Follow up question for you both: are you seeing this issue when trying to compile for the simulator or when compiling for an actual device?

The errors happen when I build to a simulator. Should I build to a device? The errors seem to be related to undeclared objects or vars

Yes, please try building for an actual device, I was able to resolve the build errors by doing that. I believe we are aware of issues building RealityKit apps for the simulator, but I will get confirmation of that on Monday.

I have an update for you: please do not build for the simulator, it looks like the ARKit APIs are disabled when compiling for the simulator, which is causing the build issues. A bug report for this issue has been filed internally.

Hi When I try to run to a device, I get the following error (see below) from Xcode.... However, I can build to the device. But then when I run the app it crashes shortly after launch (it does render the underwater scene, but before the fish and sea life are rendered it crashes). Thanks for any advice.

Details

Unable to launch com.example.apple-samplecode.Underwater

Domain: com.apple.platform.iphoneos

Code: -12

User Info: {

    IDERunOperationFailingWorker = IDELaunchiPhoneLauncher;

}

--

Request to launch com.example.apple-samplecode.Underwater failed.

Domain: com.apple.dt.deviceprocesscontrolservice

Code: 2

Failure Reason: The operation couldn’t be completed. Application info provider (FBSApplicationLibrary) returned nil for "com.example.apple-samplecode.Underwater" : Failed to launch process with bundle identifier 'com.example.apple-samplecode.Underwater'.

--

The operation couldn’t be completed. Application info provider (FBSApplicationLibrary) returned nil for "com.example.apple-samplecode.Underwater"

Domain: FBSOpenApplicationErrorDomain

Code: 4

Failure Reason: Application info provider (FBSApplicationLibrary) returned nil for "com.example.apple-samplecode.Underwater"

User Info: {

    BSErrorCodeDescription = NotFound;

}

--

Analytics Event: com.apple.dt.IDERunOperationWorkerFinished : {

    "device_model" = "iPad8,9";

    "device_osBuild" = "15.0 (19A5281h)";

    "device_platform" = "com.apple.platform.iphoneos";

    "launchSession_schemeCommand" = Run;

    "launchSession_state" = 1;

    "launchSession_targetArch" = arm64;

    "operation_duration_ms" = 11476;

    "operation_errorCode" = "-12";

    "operation_errorDomain" = "com.apple.platform.iphoneos";

    "operation_errorWorker" = IDELaunchiPhoneLauncher;

    "operation_name" = IDEiPhoneRunOperationWorkerGroup;

    "param_consoleMode" = 0;

    "param_debugger_attachToExtensions" = 0;

    "param_debugger_attachToXPC" = 1;

    "param_debugger_type" = 1;

    "param_destination_isProxy" = 0;

    "param_destination_platform" = "com.apple.platform.iphoneos";

    "param_diag_MainThreadChecker_stopOnIssue" = 0;

    "param_diag_MallocStackLogging_enableDuringAttach" = 0;

    "param_diag_MallocStackLogging_enableForXPC" = 1;

    "param_diag_allowLocationSimulation" = 1;

    "param_diag_gpu_frameCapture_enable" = 0;

    "param_diag_gpu_shaderValidation_enable" = 0;

    "param_diag_gpu_validation_enable" = 0;

    "param_diag_memoryGraphOnResourceException" = 0;

    "param_diag_queueDebugging_enable" = 1;

    "param_diag_runtimeProfile_generate" = 0;

    "param_diag_sanitizer_asan_enable" = 0;

    "param_diag_sanitizer_tsan_enable" = 0;

    "param_diag_sanitizer_tsan_stopOnIssue" = 0;

    "param_diag_sanitizer_ubsan_stopOnIssue" = 0;

    "param_diag_showNonLocalizedStrings" = 0;

    "param_diag_viewDebugging_enabled" = 1;

    "param_diag_viewDebugging_insertDylibOnLaunch" = 1;

    "param_install_style" = 0;

    "param_launcher_UID" = 2;

    "param_launcher_allowDeviceSensorReplayData" = 0;

    "param_launcher_kind" = 0;

    "param_launcher_style" = 0;

    "param_launcher_substyle" = 0;

    "param_runnable_appExtensionHostRunMode" = 0;

    "param_runnable_productType" = "com.apple.product-type.application";

    "param_runnable_swiftVersion" = "5.5";

    "param_runnable_type" = 2;

    "param_testing_launchedForTesting" = 0;

    "param_testing_suppressSimulatorApp" = 0;

    "param_testing_usingCLI" = 0;

    "sdk_canonicalName" = "iphoneos15.0";

    "sdk_osVersion" = "15.0";

    "sdk_variant" = iphoneos;

}

--

System Information

macOS Version 11.4 (Build 20F71)

Xcode 13.0 (19161.15) (Build 13A5154h)

Timestamp: 2021-06-27T15:03:13-05:00

I was able to compile this demo project for a real device using the latest Xcode Version 13.0 beta 5 (13A5212g) and commenting out targetPath: .transform in scaleIn() func in extension Entity. If i don't do that I get Extra argument 'targetPath' in call, Cannot infer contextual base in reference to member 'transform'errors.

In case it helps anyone else, the diffs I had to apply (Xcode 13.1) to compile it:

diff --git a/Underwater/Octopus.swift b/Underwater/Octopus.swift
index e447a32..7a99708 100644
--- a/Underwater/Octopus.swift
+++ b/Underwater/Octopus.swift
@@ -82,7 +82,7 @@ struct OctopusSystem: RealityKit.System {
         let scene = context.scene
         for octopus in scene.performQuery(OctopusComponent.query) {
             guard octopus.isEnabled else { continue }
-            guard var component = octopus.components[OctopusComponent] as? OctopusComponent else { continue }
+            guard var component = octopus.components[OctopusComponent.self] as? OctopusComponent else { continue }
             guard component.settings?.octopus.fearsCamera ?? false else { return }
             switch component.state {
             case .hiding:
diff --git a/Underwater/Scattering.swift b/Underwater/Scattering.swift
index 0883bdb..db3aa47 100644
--- a/Underwater/Scattering.swift
+++ b/Underwater/Scattering.swift
@@ -127,8 +127,8 @@ extension Entity {
         if let animation = try? AnimationResource.generate(with: FromToByAnimation<Transform>(
             from: transformWithZeroScale,
             to: transform,
-            duration: 1.0,
-            targetPath: .transform
+            duration: 1.0
+//            targetPath: .transform
         )) {
             playAnimation(animation)
         }
Demo code not compiling…
 
 
Q