From 9b73747b9de0ff44079ce0f4c2551e8e8a212ec6 Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Tue, 9 Apr 2024 12:28:55 -0400 Subject: [PATCH 1/6] Initial work for Apple Vision Pro --- dinghy-lib/src/apple/mod.rs | 45 ++++++++++++++++++++++++++++++++ dinghy-lib/src/apple/platform.rs | 6 +++++ dinghy-lib/src/apple/xcode.rs | 3 +++ dinghy-lib/src/lib.rs | 4 +++ dinghy-test/src/lib.rs | 2 ++ 5 files changed, 60 insertions(+) diff --git a/dinghy-lib/src/apple/mod.rs b/dinghy-lib/src/apple/mod.rs index a7e23514..720710e0 100644 --- a/dinghy-lib/src/apple/mod.rs +++ b/dinghy-lib/src/apple/mod.rs @@ -34,6 +34,7 @@ pub enum AppleSimulatorType { Ios, Watchos, Tvos, + Visionos, } impl Display for AppleSimulatorType { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -41,6 +42,7 @@ impl Display for AppleSimulatorType { AppleSimulatorType::Ios => "ios", AppleSimulatorType::Watchos => "watchos", AppleSimulatorType::Tvos => "tvos", + AppleSimulatorType::Visionos => "visionos", }; f.write_str(val) } @@ -197,6 +199,49 @@ impl PlatformManager for TvosManager { } } +pub struct VisionosManager { + devices: Vec>, +} + +impl VisionosManager { + pub fn new() -> Result> { + let devices = simulators(AppleSimulatorType::Visionos)?; + Ok(Some(Self { devices })) + } +} + +impl PlatformManager for VisionosManager { + fn devices(&self) -> Result>> { + Ok(self.devices.clone()) + } + + fn platforms(&self) -> Result>> { + ["aarch64", "aarch64-sim"] + .iter() + .map(|arch| { + let id = format!("auto-visionos-{}", arch); + let rustc_triple = if *arch != "aarch64-sim" { + format!("{}-apple-visionos", arch) + } else { + format!("aarch64-apple-visionos-sim") + }; + let simulator = if *arch == "aarch64-sim" { + Some(AppleSimulatorType::Visionos) + } else { + None + }; + AppleDevicePlatform::new( + id, + &rustc_triple, + simulator, + crate::config::PlatformConfiguration::default(), + ) + .map(|pf| pf as Box) + }) + .collect() + } +} + fn simulators(sim_type: AppleSimulatorType) -> Result>> { let sims_list = ::std::process::Command::new("xcrun") .args(&[ diff --git a/dinghy-lib/src/apple/platform.rs b/dinghy-lib/src/apple/platform.rs index e2dfe852..5d147c48 100644 --- a/dinghy-lib/src/apple/platform.rs +++ b/dinghy-lib/src/apple/platform.rs @@ -54,6 +54,12 @@ impl AppleDevicePlatform { Some(AppleSimulatorType::Watchos) => { "watchsimulator" } + Some(AppleSimulatorType::Visionos) => { + // xros and xrsimulator are sdk names. + // See https://github.com/rust-lang/rust/pull/121419#discussion_r1501908152 for + // more inconsistencies about visionOS and xrOS. + "xrsimulator" + } None => "iphoneos" }; let xcrun = process::Command::new("xcrun") diff --git a/dinghy-lib/src/apple/xcode.rs b/dinghy-lib/src/apple/xcode.rs index 96dd37a9..419306d7 100644 --- a/dinghy-lib/src/apple/xcode.rs +++ b/dinghy-lib/src/apple/xcode.rs @@ -48,6 +48,9 @@ pub fn add_plist_to_app( writeln!(plist, "WKApplication",)?; writeln!(plist, "WKWatchOnly")?; } + Some(AppleSimulatorType::Visionos) => { + todo!() + } } writeln!(plist, r#""#)?; Ok(()) diff --git a/dinghy-lib/src/lib.rs b/dinghy-lib/src/lib.rs index a5669449..ed055d58 100644 --- a/dinghy-lib/src/lib.rs +++ b/dinghy-lib/src/lib.rs @@ -28,6 +28,7 @@ use crate::apple::{ IosManager, TvosManager, WatchosManager, + VisionosManager, }; use crate::platform::regular_platform::RegularPlatform; @@ -71,6 +72,9 @@ impl Dinghy { if let Some(man) = WatchosManager::new().context("Could not initialize tvOS manager")? { managers.push(Box::new(man)); } + if let Some(man) = VisionosManager::new().context("Could not initialize tvOS manager")? { + managers.push(Box::new(man)); + } } let mut devices = vec![]; diff --git a/dinghy-test/src/lib.rs b/dinghy-test/src/lib.rs index 1798e7c9..8d4169dc 100644 --- a/dinghy-test/src/lib.rs +++ b/dinghy-test/src/lib.rs @@ -9,6 +9,7 @@ pub fn test_project_path() -> PathBuf { target_os = "ios", target_os = "watchos", target_os = "tvos", + target_os = "visionos", target_os = "android" )) || env::var("DINGHY").is_ok() { let current_exe = env::current_exe().expect("Current exe path not accessible"); @@ -37,6 +38,7 @@ pub fn try_test_file_path(test_data_id: &str) -> Option { target_os = "ios", target_os = "watchos", target_os = "tvos", + target_os = "visionos", target_os = "android" )) || env::var("DINGHY").is_ok() { current_exe From 395db75118d36eee7852c099e8484b91b9221ae7 Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Tue, 30 Apr 2024 12:03:25 -0400 Subject: [PATCH 2/6] Finish up work for visionOS simulator tests --- dinghy-lib/src/apple/xcode.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dinghy-lib/src/apple/xcode.rs b/dinghy-lib/src/apple/xcode.rs index 419306d7..5ca94fe4 100644 --- a/dinghy-lib/src/apple/xcode.rs +++ b/dinghy-lib/src/apple/xcode.rs @@ -49,7 +49,10 @@ pub fn add_plist_to_app( writeln!(plist, "WKWatchOnly")?; } Some(AppleSimulatorType::Visionos) => { - todo!() + writeln!( + plist, + "UIDeviceFamily 7 " + )?; } } writeln!(plist, r#""#)?; From 615428bc15096856adfd3844c6f3ccead84d29e3 Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Thu, 2 May 2024 14:59:07 -0400 Subject: [PATCH 3/6] Add visionOS to github matrix --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3570a309..e4bba346 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,7 +44,7 @@ jobs: strategy: matrix: os: [ macOS-13, macOS-14 ] - sim: [ tvOS, watchOS ] + sim: [ tvOS, watchOS, visionOS ] runs-on: ${{matrix.os}} steps: From 8971f342a1a73a713d5b856dd5073dedeb0f86a1 Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Fri, 3 May 2024 11:36:20 -0400 Subject: [PATCH 4/6] Add debug line for ci --- .travis.apple-third-tier.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.apple-third-tier.sh b/.travis.apple-third-tier.sh index 6e05cf2c..4b0c18d0 100755 --- a/.travis.apple-third-tier.sh +++ b/.travis.apple-third-tier.sh @@ -96,7 +96,7 @@ then if [ "$(uname -m)" = "arm64" ]; then title "••••• Darwin: visionOS simulator tests •••••" title "boot a simulator" - xcrun simctl list devicetypes vision + xcrun simctl list devicetypes VISIONOS_DEVICE_TYPE=$(xcrun simctl list devicetypes vision -j | jq -r '.devicetypes[0].identifier') VISIONOS_RUNTIME_ID=$(xcrun simctl list runtimes | grep visionOS | cut -d ' ' -f 7 | tail -1) export VISIONOS_SIM_ID=$(xcrun simctl create My-apple-vision-pro $VISIONOS_DEVICE_TYPE $VISIONOS_RUNTIME_ID) From 65ca515508f4cbb9bf18b97a6edcabf388af178a Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Fri, 3 May 2024 11:48:10 -0400 Subject: [PATCH 5/6] More debug on ci --- .travis.apple-third-tier.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.apple-third-tier.sh b/.travis.apple-third-tier.sh index 4b0c18d0..725883ef 100755 --- a/.travis.apple-third-tier.sh +++ b/.travis.apple-third-tier.sh @@ -96,7 +96,7 @@ then if [ "$(uname -m)" = "arm64" ]; then title "••••• Darwin: visionOS simulator tests •••••" title "boot a simulator" - xcrun simctl list devicetypes + xcrun simctl list VISIONOS_DEVICE_TYPE=$(xcrun simctl list devicetypes vision -j | jq -r '.devicetypes[0].identifier') VISIONOS_RUNTIME_ID=$(xcrun simctl list runtimes | grep visionOS | cut -d ' ' -f 7 | tail -1) export VISIONOS_SIM_ID=$(xcrun simctl create My-apple-vision-pro $VISIONOS_DEVICE_TYPE $VISIONOS_RUNTIME_ID) From f7d90c0d804d444fd9543a7577963e3b26a57984 Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Fri, 3 May 2024 12:00:44 -0400 Subject: [PATCH 6/6] More debug in ci --- .github/workflows/test.yml | 5 ++++- .travis.apple-third-tier.sh | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e4bba346..580cd31f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,7 +44,10 @@ jobs: strategy: matrix: os: [ macOS-13, macOS-14 ] - sim: [ tvOS, watchOS, visionOS ] + sim: [ tvOS, watchOS ] + include: + - os: macos-14 + sim: visionOS runs-on: ${{matrix.os}} steps: diff --git a/.travis.apple-third-tier.sh b/.travis.apple-third-tier.sh index 725883ef..9eebedd3 100755 --- a/.travis.apple-third-tier.sh +++ b/.travis.apple-third-tier.sh @@ -96,7 +96,9 @@ then if [ "$(uname -m)" = "arm64" ]; then title "••••• Darwin: visionOS simulator tests •••••" title "boot a simulator" - xcrun simctl list + xcrun simctl list devices vision + system_profiler SPDeveloperToolsDataType + xcodebuild -showsdks VISIONOS_DEVICE_TYPE=$(xcrun simctl list devicetypes vision -j | jq -r '.devicetypes[0].identifier') VISIONOS_RUNTIME_ID=$(xcrun simctl list runtimes | grep visionOS | cut -d ' ' -f 7 | tail -1) export VISIONOS_SIM_ID=$(xcrun simctl create My-apple-vision-pro $VISIONOS_DEVICE_TYPE $VISIONOS_RUNTIME_ID)