Skip to content

Commit

Permalink
feat(cli): use devicetl to connect with iOS 17 devices (#7971)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Oct 7, 2023
1 parent 1c9f3db commit b2f1772
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 45 deletions.
6 changes: 6 additions & 0 deletions .changes/devicectl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-cli": patch:feat
"@tauri-apps/cli": patch:feat
---

Use `devicectl` to connect to iOS 17+ devices on macOS 14+.
1 change: 1 addition & 0 deletions .github/workflows/test-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ jobs:
cargo update -p toml@0.7.8 --precise 0.7.6
cargo update -p toml_edit@0.19.15 --precise 0.19.14
cargo update -p cfg-expr@0.15.5 --precise 0.15.4
cargo update -p system-deps --precise 6.1.1
- name: test
uses: actions-rs/cargo@v1
Expand Down
7 changes: 3 additions & 4 deletions core/tauri-runtime/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,9 @@ impl<T: UserEvent, R: Runtime<T>> PendingWindow<T, R> {
protocol: H,
) {
let uri_scheme = uri_scheme.into();
self.uri_scheme_protocols.insert(
uri_scheme,
Box::new(move |data, responder| (protocol)(data, responder)),
);
self
.uri_scheme_protocols
.insert(uri_scheme, Box::new(protocol));
}

#[cfg(target_os = "android")]
Expand Down
2 changes: 1 addition & 1 deletion core/tauri/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fn replace_csp_nonce(
.into_iter()
.map(|n| format!("'nonce-{n}'"))
.collect::<Vec<String>>();
let sources = csp.entry(directive.into()).or_insert_with(Default::default);
let sources = csp.entry(directive.into()).or_default();
let self_source = "'self'".to_string();
if !sources.contains(&self_source) {
sources.push(self_source);
Expand Down
2 changes: 1 addition & 1 deletion core/tauri/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,7 @@ impl<R: Runtime> Window<R> {
window_label,
event,
})
.or_insert_with(Default::default)
.or_default()
.insert(event_id);

Ok(event_id)
Expand Down
10 changes: 4 additions & 6 deletions tooling/bundler/src/bundle/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,8 @@ impl CommandExt for Command {
let mut lines = stdout_lines_.lock().unwrap();
loop {
buf.clear();
match tauri_utils::io::read_line(&mut stdout, &mut buf) {
Ok(s) if s == 0 => break,
_ => (),
if let Ok(0) = tauri_utils::io::read_line(&mut stdout, &mut buf) {
break;
}
debug!(action = "stdout"; "{}", String::from_utf8_lossy(&buf));
lines.extend(buf.clone());
Expand All @@ -182,9 +181,8 @@ impl CommandExt for Command {
let mut lines = stderr_lines_.lock().unwrap();
loop {
buf.clear();
match tauri_utils::io::read_line(&mut stderr, &mut buf) {
Ok(s) if s == 0 => break,
_ => (),
if let Ok(0) = tauri_utils::io::read_line(&mut stderr, &mut buf) {
break;
}
debug!(action = "stderr"; "{}", String::from_utf8_lossy(&buf));
lines.extend(buf.clone());
Expand Down
78 changes: 62 additions & 16 deletions tooling/cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tooling/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ name = "cargo-tauri"
path = "src/main.rs"

[dependencies]
cargo-mobile2 = { version = "0.6", default-features = false }
cargo-mobile2 = { version = "0.7", default-features = false }
textwrap = { version = "0.11.0", features = [ "term_size" ] }
jsonrpsee = { version = "0.16", features = [ "server" ] }
jsonrpsee-core = "0.16"
Expand Down
5 changes: 2 additions & 3 deletions tooling/cli/src/interface/rust/desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,8 @@ fn build_dev_app<F: FnOnce(Option<i32>, ExitReason) + Send + 'static>(
let mut io_stderr = std::io::stderr();
loop {
buf.clear();
match tauri_utils::io::read_line(&mut stderr, &mut buf) {
Ok(s) if s == 0 => break,
_ => (),
if let Ok(0) = tauri_utils::io::read_line(&mut stderr, &mut buf) {
break;
}
let _ = io_stderr.write_all(&buf);
if !buf.ends_with(&[b'\r']) {
Expand Down
10 changes: 4 additions & 6 deletions tooling/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,8 @@ impl CommandExt for Command {
let mut lines = stdout_lines_.lock().unwrap();
loop {
buf.clear();
match tauri_utils::io::read_line(&mut stdout, &mut buf) {
Ok(s) if s == 0 => break,
_ => (),
if let Ok(0) = tauri_utils::io::read_line(&mut stdout, &mut buf) {
break;
}
debug!(action = "stdout"; "{}", String::from_utf8_lossy(&buf));
lines.extend(buf.clone());
Expand All @@ -295,9 +294,8 @@ impl CommandExt for Command {
let mut lines = stderr_lines_.lock().unwrap();
loop {
buf.clear();
match tauri_utils::io::read_line(&mut stderr, &mut buf) {
Ok(s) if s == 0 => break,
_ => (),
if let Ok(0) = tauri_utils::io::read_line(&mut stderr, &mut buf) {
break;
}
debug!(action = "stderr"; "{}", String::from_utf8_lossy(&buf));
lines.extend(buf.clone());
Expand Down
13 changes: 6 additions & 7 deletions tooling/cli/src/mobile/ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use cargo_mobile2::{
Config as AppleConfig, Metadata as AppleMetadata, Platform as ApplePlatform,
Raw as RawAppleConfig,
},
device::Device,
ios_deploy, simctl,
device::{self, Device},
target::Target,
teams::find_development_teams,
},
Expand Down Expand Up @@ -146,8 +145,8 @@ pub fn get_config(
(config, metadata)
}

fn ios_deploy_device_prompt<'a>(env: &'_ Env, target: Option<&str>) -> Result<Device<'a>> {
let device_list = ios_deploy::device_list(env)
fn connected_device_prompt<'a>(env: &'_ Env, target: Option<&str>) -> Result<Device<'a>> {
let device_list = device::list_devices(env)
.map_err(|cause| anyhow::anyhow!("Failed to detect connected iOS devices: {cause}"))?;
if !device_list.is_empty() {
let device = if let Some(t) = target {
Expand Down Expand Up @@ -192,8 +191,8 @@ fn ios_deploy_device_prompt<'a>(env: &'_ Env, target: Option<&str>) -> Result<De
}
}

fn simulator_prompt(env: &'_ Env, target: Option<&str>) -> Result<simctl::Device> {
let simulator_list = simctl::device_list(env).map_err(|cause| {
fn simulator_prompt(env: &'_ Env, target: Option<&str>) -> Result<device::Simulator> {
let simulator_list = device::list_simulators(env).map_err(|cause| {
anyhow::anyhow!("Failed to detect connected iOS Simulator devices: {cause}")
})?;
if !simulator_list.is_empty() {
Expand Down Expand Up @@ -233,7 +232,7 @@ fn simulator_prompt(env: &'_ Env, target: Option<&str>) -> Result<simctl::Device
}

fn device_prompt<'a>(env: &'_ Env, target: Option<&str>) -> Result<Device<'a>> {
if let Ok(device) = ios_deploy_device_prompt(env, target) {
if let Ok(device) = connected_device_prompt(env, target) {
Ok(device)
} else {
let simulator = simulator_prompt(env, target)?;
Expand Down

0 comments on commit b2f1772

Please sign in to comment.