1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
use super::*;
/// Target metadata helpers for `AppleTargetKind`.
impl AppleTargetKind {
/// Returns the canonical CLI label for this Apple target.
///
/// # Returns
///
/// - `&'static str` - Target label string.
#[must_use]
pub fn as_label(&self) -> &'static str {
match self {
Self::IosSim => APPLE_LABEL_IOS_SIM,
Self::IpadSim => APPLE_LABEL_IPAD_SIM,
Self::IosDevice => APPLE_LABEL_IOS_DEVICE,
Self::IpadDevice => APPLE_LABEL_IPAD_DEVICE,
Self::WatchOsSim => APPLE_LABEL_WATCHOS_SIM,
Self::WatchOsDevice => APPLE_LABEL_WATCHOS_DEVICE,
}
}
/// Returns the Rust target triple for compiling the static library.
///
/// # Returns
///
/// - `&'static str` - Rust compiler target triple.
#[must_use]
pub fn rust_triple(&self) -> &'static str {
match self {
Self::IosSim | Self::IpadSim => APPLE_TRIPLE_IOS_SIM,
Self::IosDevice | Self::IpadDevice => APPLE_TRIPLE_IOS_DEVICE,
Self::WatchOsSim => APPLE_TRIPLE_WATCHOS_SIM,
Self::WatchOsDevice => APPLE_TRIPLE_WATCHOS_DEVICE,
}
}
/// Returns the Xcode `--sdk` name required to compile and link this target.
///
/// # Returns
///
/// - `&'static str` - Xcode SDK identifier.
#[must_use]
pub fn xcode_sdk(&self) -> &'static str {
match self {
Self::IosSim | Self::IpadSim => APPLE_SDK_IPHONE_SIM,
Self::IosDevice | Self::IpadDevice => APPLE_SDK_IPHONE_OS,
Self::WatchOsSim => APPLE_SDK_WATCH_SIM,
Self::WatchOsDevice => APPLE_SDK_WATCH_OS,
}
}
/// Returns whether this target runs inside an Apple Simulator.
///
/// # Returns
///
/// - `bool` - `true` for simulator targets.
#[must_use]
pub fn is_simulator(&self) -> bool {
matches!(self, Self::IosSim | Self::IpadSim | Self::WatchOsSim)
}
/// Returns whether this target builds an Apple watchOS SwiftUI bundle.
///
/// # Returns
///
/// - `bool` - `true` for watchOS targets.
#[must_use]
pub fn is_watchos(&self) -> bool {
matches!(self, Self::WatchOsSim | Self::WatchOsDevice)
}
/// Returns whether this target prefers an iPad simulator device.
///
/// # Returns
///
/// - `bool` - `true` for iPadOS targets.
#[must_use]
pub fn is_ipad(&self) -> bool {
matches!(self, Self::IpadSim | Self::IpadDevice)
}
/// Returns the `.app` bundle directory name.
///
/// # Returns
///
/// - `&'static str` - `EuvShowcase.app` or `EuvWatch.app`.
#[must_use]
pub fn default_bundle_name(&self) -> &'static str {
if self.is_watchos() {
APPLE_WATCHOS_BUNDLE_NAME
} else {
APPLE_IOS_BUNDLE_NAME
}
}
/// Returns the executable binary filename inside the `.app` bundle.
///
/// # Returns
///
/// - `&'static str` - `EuvShowcase` or `EuvWatch`.
#[must_use]
pub fn default_executable_name(&self) -> &'static str {
if self.is_watchos() {
APPLE_WATCHOS_EXEC_NAME
} else {
APPLE_IOS_EXEC_NAME
}
}
/// Returns the default `CFBundleIdentifier`.
///
/// # Returns
///
/// - `&'static str` - Default bundle identifier string.
#[must_use]
pub fn default_bundle_id(&self) -> &'static str {
if self.is_watchos() {
APPLE_WATCHOS_BUNDLE_ID
} else {
APPLE_IOS_BUNDLE_ID
}
}
/// Returns the default relative output directory under `dist/`.
///
/// # Returns
///
/// - `&'static str` - `"ios"` or `"wearable/watchos"`.
#[must_use]
pub fn default_out_subdir(&self) -> &'static str {
if self.is_watchos() {
APPLE_OUT_SUBDIR_WATCHOS
} else {
APPLE_OUT_SUBDIR_IOS
}
}
/// Returns the staging directory name under `target/mobile-hosts/`.
///
/// # Returns
///
/// - `&'static str` - `"ios-host"` or `"watchos-host"`.
#[must_use]
pub fn host_dir_name(&self) -> &'static str {
if self.is_watchos() {
APPLE_HOST_DIR_WATCHOS
} else {
APPLE_HOST_DIR_IOS
}
}
}
/// Default configuration builder for `AppleBuildConfig`.
impl Default for AppleBuildConfig {
/// Creates a release hardware-rendered iOS Simulator build configuration rooted at `.`.
///
/// # Returns
///
/// - `Self` - Default `AppleBuildConfig`.
fn default() -> Self {
Self {
workspace_root: PathBuf::from("."),
target_kind: AppleTargetKind::IosSim,
render_mode: RenderArg::Hardware,
app_version: None,
build_number: None,
bundle_id: None,
out_dir: None,
build_dir: None,
archive_path: None,
codesign_identity: None,
sim_udid: None,
release: true,
no_launch: false,
shell_only: false,
}
}
}