pub enum ApplePlatform {
Show 13 variants
Unknown = 0,
MacOS = 1,
IOS = 2,
TvOS = 3,
WatchOS = 4,
BridgeOS = 5,
MacCatalyst = 6,
IOSSimulator = 7,
TvOSSimulator = 8,
WatchOSSimulator = 9,
DriverKit = 10,
XrOS = 11,
XrOSSimulator = 12,
}Expand description
Apple platform enumeration.
Matches LLVM’s MachO::PlatformType identifiers. Numeric discriminants
are stable and correspond to Mach-O platform IDs, so PartialOrd/Ord
order platforms by ID.
Variants§
Unknown = 0
MacOS = 1
IOS = 2
TvOS = 3
WatchOS = 4
BridgeOS = 5
MacCatalyst = 6
IOSSimulator = 7
TvOSSimulator = 8
WatchOSSimulator = 9
DriverKit = 10
XrOS = 11
XrOSSimulator = 12
Implementations§
Source§impl ApplePlatform
impl ApplePlatform
Sourcepub const ALL: [ApplePlatform; 13]
pub const ALL: [ApplePlatform; 13]
All platform variants in Mach-O ID order.
Sourcepub fn iter() -> impl Iterator<Item = ApplePlatform>
pub fn iter() -> impl Iterator<Item = ApplePlatform>
Iterate over all platform variants in Mach-O ID order.
Examples found in repository?
3fn main() {
4 println!("=== Apple Platforms (from LLVM MachO.def) ===\n");
5 println!(
6 "{:<20} {:>2} {:<18} {:<18} {:<22} {}",
7 "Platform", "ID", "Target", "TAPI Target", "Marketing", "SDK"
8 );
9 println!("{}", "-".repeat(100));
10
11 for ap in ApplePlatform::iter() {
12 let p = Platform::from(ap);
13 println!(
14 "{:<20} {:>2} {:<18} {:<18} {:<22} {}",
15 p.platform,
16 p.id,
17 p.target,
18 p.tapi_target,
19 p.marketing,
20 p.sdk.unwrap_or("-"),
21 );
22 }
23
24 println!("\nSimulators (sim → device):");
25 for ap in ApplePlatform::iter().filter(|p| p.is_simulator()) {
26 println!(" {:<22} → {}", ap, ap.device());
27 }
28
29 println!("\nDevice platforms (device → sim):");
30 for ap in ApplePlatform::iter().filter(|p| p.is_device()) {
31 let sim = ap.simulator()
32 .map(|s| s.to_string())
33 .unwrap_or_else(|| "(none)".to_string());
34 println!(" {:<22} → {}", ap, sim);
35 }
36}Sourcepub fn from_id(id: u32) -> Option<Self>
pub fn from_id(id: u32) -> Option<Self>
Create from a Mach-O platform ID.
Returns None for unrecognised IDs instead of silently falling back to
Unknown. Use TryFrom<u32> for the same behaviour as a trait impl.
Sourcepub fn from_rust_triple(target: &str) -> Result<Self, ParsePlatformError>
pub fn from_rust_triple(target: &str) -> Result<Self, ParsePlatformError>
Create from a Rust target triple (e.g. "aarch64-apple-ios-sim").
Returns an error if the triple is not a recognised Apple target.
use apple_platforms::platform::ApplePlatform;
assert_eq!(ApplePlatform::from_rust_triple("aarch64-apple-darwin").unwrap(), ApplePlatform::MacOS);
assert_eq!(ApplePlatform::from_rust_triple("aarch64-apple-ios-sim").unwrap(), ApplePlatform::IOSSimulator);
assert!(ApplePlatform::from_rust_triple("x86_64-unknown-linux-gnu").is_err());Examples found in repository?
3fn main() {
4 println!("=== Rust Target → SDK Name ===\n");
5
6 let targets = [
7 "aarch64-apple-darwin",
8 "x86_64-apple-darwin",
9 "aarch64-apple-ios",
10 "aarch64-apple-ios-sim",
11 "aarch64-apple-ios-macabi",
12 "aarch64-apple-tvos",
13 "aarch64-apple-tvos-sim",
14 "aarch64-apple-watchos",
15 "aarch64-apple-watchos-sim",
16 "aarch64-apple-visionos",
17 "aarch64-apple-visionos-sim",
18 "aarch64-apple-driverkit",
19 "x86_64-unknown-linux-gnu", // not Apple — should be None
20 ];
21
22 println!("{:<42} {:<18} {}", "Rust triple", "SDK", "Platform");
23 println!("{}", "-".repeat(85));
24 for target in targets {
25 let sdk = triple::to_sdk(target).unwrap_or("(unknown)");
26 let platform = ApplePlatform::from_rust_triple(target)
27 .map(|p| p.to_string())
28 .unwrap_or_else(|_| "(not Apple)".to_string());
29 println!(" {target:<40} {sdk:<18} {platform}");
30 }
31}Sourcepub fn sdk(self) -> Option<&'static str>
pub fn sdk(self) -> Option<&'static str>
The SDK name for xcrun --sdk <name>.
Returns None only for the Unknown variant.
Note: MacCatalyst builds use the macOS SDK
("macosx") with the macabi ABI environment.
use apple_platforms::platform::ApplePlatform;
assert_eq!(ApplePlatform::MacOS.sdk(), Some("macosx"));
assert_eq!(ApplePlatform::IOS.sdk(), Some("iphoneos"));
assert_eq!(ApplePlatform::IOSSimulator.sdk(), Some("iphonesimulator"));
assert_eq!(ApplePlatform::MacCatalyst.sdk(), Some("macosx"));
assert_eq!(ApplePlatform::Unknown.sdk(), None);Sourcepub fn is_simulator(self) -> bool
pub fn is_simulator(self) -> bool
Whether this is a simulator platform.
Examples found in repository?
3fn main() {
4 println!("=== Apple Platforms (from LLVM MachO.def) ===\n");
5 println!(
6 "{:<20} {:>2} {:<18} {:<18} {:<22} {}",
7 "Platform", "ID", "Target", "TAPI Target", "Marketing", "SDK"
8 );
9 println!("{}", "-".repeat(100));
10
11 for ap in ApplePlatform::iter() {
12 let p = Platform::from(ap);
13 println!(
14 "{:<20} {:>2} {:<18} {:<18} {:<22} {}",
15 p.platform,
16 p.id,
17 p.target,
18 p.tapi_target,
19 p.marketing,
20 p.sdk.unwrap_or("-"),
21 );
22 }
23
24 println!("\nSimulators (sim → device):");
25 for ap in ApplePlatform::iter().filter(|p| p.is_simulator()) {
26 println!(" {:<22} → {}", ap, ap.device());
27 }
28
29 println!("\nDevice platforms (device → sim):");
30 for ap in ApplePlatform::iter().filter(|p| p.is_device()) {
31 let sim = ap.simulator()
32 .map(|s| s.to_string())
33 .unwrap_or_else(|| "(none)".to_string());
34 println!(" {:<22} → {}", ap, sim);
35 }
36}Sourcepub fn is_device(self) -> bool
pub fn is_device(self) -> bool
Whether this is a real-device platform (non-simulator, non-Unknown).
Examples found in repository?
3fn main() {
4 println!("=== Apple Platforms (from LLVM MachO.def) ===\n");
5 println!(
6 "{:<20} {:>2} {:<18} {:<18} {:<22} {}",
7 "Platform", "ID", "Target", "TAPI Target", "Marketing", "SDK"
8 );
9 println!("{}", "-".repeat(100));
10
11 for ap in ApplePlatform::iter() {
12 let p = Platform::from(ap);
13 println!(
14 "{:<20} {:>2} {:<18} {:<18} {:<22} {}",
15 p.platform,
16 p.id,
17 p.target,
18 p.tapi_target,
19 p.marketing,
20 p.sdk.unwrap_or("-"),
21 );
22 }
23
24 println!("\nSimulators (sim → device):");
25 for ap in ApplePlatform::iter().filter(|p| p.is_simulator()) {
26 println!(" {:<22} → {}", ap, ap.device());
27 }
28
29 println!("\nDevice platforms (device → sim):");
30 for ap in ApplePlatform::iter().filter(|p| p.is_device()) {
31 let sim = ap.simulator()
32 .map(|s| s.to_string())
33 .unwrap_or_else(|| "(none)".to_string());
34 println!(" {:<22} → {}", ap, sim);
35 }
36}Sourcepub fn device(self) -> Self
pub fn device(self) -> Self
The corresponding device (non-simulator) platform.
Returns self if already a device platform.
use apple_platforms::platform::ApplePlatform;
assert_eq!(ApplePlatform::IOSSimulator.device(), ApplePlatform::IOS);
assert_eq!(ApplePlatform::IOS.device(), ApplePlatform::IOS);Examples found in repository?
3fn main() {
4 println!("=== Apple Platforms (from LLVM MachO.def) ===\n");
5 println!(
6 "{:<20} {:>2} {:<18} {:<18} {:<22} {}",
7 "Platform", "ID", "Target", "TAPI Target", "Marketing", "SDK"
8 );
9 println!("{}", "-".repeat(100));
10
11 for ap in ApplePlatform::iter() {
12 let p = Platform::from(ap);
13 println!(
14 "{:<20} {:>2} {:<18} {:<18} {:<22} {}",
15 p.platform,
16 p.id,
17 p.target,
18 p.tapi_target,
19 p.marketing,
20 p.sdk.unwrap_or("-"),
21 );
22 }
23
24 println!("\nSimulators (sim → device):");
25 for ap in ApplePlatform::iter().filter(|p| p.is_simulator()) {
26 println!(" {:<22} → {}", ap, ap.device());
27 }
28
29 println!("\nDevice platforms (device → sim):");
30 for ap in ApplePlatform::iter().filter(|p| p.is_device()) {
31 let sim = ap.simulator()
32 .map(|s| s.to_string())
33 .unwrap_or_else(|| "(none)".to_string());
34 println!(" {:<22} → {}", ap, sim);
35 }
36}Sourcepub fn simulator(self) -> Option<Self>
pub fn simulator(self) -> Option<Self>
The corresponding simulator platform, or None if this platform has
no simulator counterpart (e.g. macOS, DriverKit, BridgeOS).
Returns Some(self) if already a simulator.
use apple_platforms::platform::ApplePlatform;
assert_eq!(ApplePlatform::IOS.simulator(), Some(ApplePlatform::IOSSimulator));
assert_eq!(ApplePlatform::IOSSimulator.simulator(), Some(ApplePlatform::IOSSimulator));
assert_eq!(ApplePlatform::MacOS.simulator(), None);
assert_eq!(ApplePlatform::DriverKit.simulator(), None);Examples found in repository?
3fn main() {
4 println!("=== Apple Platforms (from LLVM MachO.def) ===\n");
5 println!(
6 "{:<20} {:>2} {:<18} {:<18} {:<22} {}",
7 "Platform", "ID", "Target", "TAPI Target", "Marketing", "SDK"
8 );
9 println!("{}", "-".repeat(100));
10
11 for ap in ApplePlatform::iter() {
12 let p = Platform::from(ap);
13 println!(
14 "{:<20} {:>2} {:<18} {:<18} {:<22} {}",
15 p.platform,
16 p.id,
17 p.target,
18 p.tapi_target,
19 p.marketing,
20 p.sdk.unwrap_or("-"),
21 );
22 }
23
24 println!("\nSimulators (sim → device):");
25 for ap in ApplePlatform::iter().filter(|p| p.is_simulator()) {
26 println!(" {:<22} → {}", ap, ap.device());
27 }
28
29 println!("\nDevice platforms (device → sim):");
30 for ap in ApplePlatform::iter().filter(|p| p.is_device()) {
31 let sim = ap.simulator()
32 .map(|s| s.to_string())
33 .unwrap_or_else(|| "(none)".to_string());
34 println!(" {:<22} → {}", ap, sim);
35 }
36}Trait Implementations§
Source§impl Clone for ApplePlatform
impl Clone for ApplePlatform
Source§fn clone(&self) -> ApplePlatform
fn clone(&self) -> ApplePlatform
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ApplePlatform
impl Debug for ApplePlatform
Source§impl Default for ApplePlatform
impl Default for ApplePlatform
Source§impl Display for ApplePlatform
impl Display for ApplePlatform
Source§impl From<ApplePlatform> for Platform
impl From<ApplePlatform> for Platform
Source§fn from(value: ApplePlatform) -> Self
fn from(value: ApplePlatform) -> Self
Source§impl FromStr for ApplePlatform
impl FromStr for ApplePlatform
Source§impl Hash for ApplePlatform
impl Hash for ApplePlatform
Source§impl Ord for ApplePlatform
impl Ord for ApplePlatform
Source§fn cmp(&self, other: &ApplePlatform) -> Ordering
fn cmp(&self, other: &ApplePlatform) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ApplePlatform
impl PartialEq for ApplePlatform
Source§impl PartialOrd for ApplePlatform
impl PartialOrd for ApplePlatform
Source§impl TryFrom<Platform> for ApplePlatform
Convert a Platform back to an ApplePlatform by its numeric ID.
impl TryFrom<Platform> for ApplePlatform
Convert a Platform back to an ApplePlatform by its numeric ID.
Fails if p.id does not correspond to a known platform.