diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8d1b4f7f..1555265d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,6 +47,9 @@ jobs: matrix: os: [ macOS-14, macOS-15 ] 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 6e05cf2c..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 devicetypes vision + 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) diff --git a/dinghy-lib/src/apple/mod.rs b/dinghy-lib/src/apple/mod.rs index 22359c12..f871baed 100644 --- a/dinghy-lib/src/apple/mod.rs +++ b/dinghy-lib/src/apple/mod.rs @@ -36,6 +36,7 @@ pub enum AppleSimulatorType { Ios, Watchos, Tvos, + Visionos, } impl Display for AppleSimulatorType { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -43,6 +44,7 @@ impl Display for AppleSimulatorType { AppleSimulatorType::Ios => "ios", AppleSimulatorType::Watchos => "watchos", AppleSimulatorType::Tvos => "tvos", + AppleSimulatorType::Visionos => "visionos", }; f.write_str(val) } @@ -199,6 +201,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 6fae160b..8380b590 100644 --- a/dinghy-lib/src/apple/platform.rs +++ b/dinghy-lib/src/apple/platform.rs @@ -48,6 +48,10 @@ impl AppleDevicePlatform { Some(AppleSimulatorType::Ios) => "iphonesimulator", Some(AppleSimulatorType::Tvos) => "appletvsimulator", Some(AppleSimulatorType::Watchos) => "watchsimulator", + // xros and xrsimulator are sdk names. + // See https://github.com/rust-lang/rust/pull/121419#discussion_r1501908152 for + // more inconsistencies about visionOS and xrOS. + Some(AppleSimulatorType::Visionos) => "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 e6056bcd..ae76cf55 100644 --- a/dinghy-lib/src/apple/xcode.rs +++ b/dinghy-lib/src/apple/xcode.rs @@ -48,6 +48,12 @@ pub fn add_plist_to_app( writeln!(plist, "WKApplication",)?; writeln!(plist, "WKWatchOnly")?; } + Some(AppleSimulatorType::Visionos) => { + writeln!( + plist, + "UIDeviceFamily 7 " + )?; + } } writeln!(plist, r#""#)?; Ok(()) diff --git a/dinghy-lib/src/lib.rs b/dinghy-lib/src/lib.rs index 81131bdf..01c5c46c 100644 --- a/dinghy-lib/src/lib.rs +++ b/dinghy-lib/src/lib.rs @@ -21,7 +21,12 @@ pub mod utils; pub use crate::config::Configuration; #[cfg(target_os = "macos")] -use crate::apple::{IosManager, TvosManager, WatchosManager}; +use crate::apple::{ + IosManager, + TvosManager, + WatchosManager, + VisionosManager, +}; use crate::config::PlatformConfiguration; use crate::platform::regular_platform::RegularPlatform; @@ -65,6 +70,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)); + } } if let Some(man) = plugin::PluginManager::probe(conf.clone()) { managers.push(Box::new(man)); diff --git a/dinghy-test/src/lib.rs b/dinghy-test/src/lib.rs index 04cfad83..8753dc6e 100644 --- a/dinghy-test/src/lib.rs +++ b/dinghy-test/src/lib.rs @@ -8,6 +8,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() { @@ -36,6 +37,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() {