From 3ad2427dc08f12c61edc726b587acce32eca1080 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Sun, 15 Sep 2024 07:37:56 -0300 Subject: [PATCH] feat(cli): enhance iOS logs (#10961) enhance simulator and device run output by only displaying app logs by default, and printing full process logs when pedantic verbosity is requested ref https://github.com/tauri-apps/cargo-mobile2/pull/388 --- .changes/update-ios-logging.md | 6 + Cargo.lock | 376 ++++++++++++++++++++++- Cargo.toml | 1 + crates/tauri-cli/Cargo.toml | 2 +- crates/tauri-cli/src/mobile/ios/build.rs | 8 +- crates/tauri-cli/src/mobile/ios/dev.rs | 5 +- examples/api/src-tauri/Cargo.toml | 1 + examples/api/src-tauri/src/lib.rs | 5 + 8 files changed, 383 insertions(+), 21 deletions(-) create mode 100644 .changes/update-ios-logging.md diff --git a/.changes/update-ios-logging.md b/.changes/update-ios-logging.md new file mode 100644 index 000000000..cf64687c5 --- /dev/null +++ b/.changes/update-ios-logging.md @@ -0,0 +1,6 @@ +--- +"tauri-cli": patch:enhance +"@tauri-apps/cli": patch:enhance +--- + +Only render app logs on iOS unless `-vv` is provided to the `ios dev` command. diff --git a/Cargo.lock b/Cargo.lock index 9c681fd6b..dddf9f737 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,6 +73,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom 0.2.15", + "once_cell", + "version_check", +] + [[package]] name = "ahash" version = "0.8.11" @@ -129,6 +140,23 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" +[[package]] +name = "android_log-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ecc8056bf6ab9892dcd53216c83d1597487d7dacac16c8df6b877d127df9937" + +[[package]] +name = "android_logger" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b07e8e73d720a1f2e4b6014766e6039fd2e96a4fa44e2a78d0e1fa2ff49826" +dependencies = [ + "android_log-sys", + "env_filter", + "log", +] + [[package]] name = "android_system_properties" version = "0.1.5" @@ -202,6 +230,7 @@ dependencies = [ "serde_json", "tauri", "tauri-build", + "tauri-plugin-log", "tauri-plugin-sample", "tiny_http", ] @@ -540,6 +569,18 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b81e1519b0d82120d2fd469d5bfb2919a9361c48b02d82d04befc1cdd2002452" +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + [[package]] name = "blake2" version = "0.10.6" @@ -592,6 +633,30 @@ dependencies = [ "cipher", ] +[[package]] +name = "borsh" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6362ed55def622cddc70a4746a68554d7b687713770de539e59a739b249f8ed" +dependencies = [ + "borsh-derive", + "cfg_aliases", +] + +[[package]] +name = "borsh-derive" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ef8005764f53cd4dca619f5bf64cafd4664dada50ece25e4d81de54c80cc0b" +dependencies = [ + "once_cell", + "proc-macro-crate 3.2.0", + "proc-macro2", + "quote", + "syn 2.0.76", + "syn_derive", +] + [[package]] name = "brotli" version = "6.0.0" @@ -647,6 +712,39 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "byte-unit" +version = "5.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ac19bdf0b2665407c39d82dbc937e951e7e2001609f0fb32edd0af45a2d63e" +dependencies = [ + "rust_decimal", + "serde", + "utf8-width", +] + +[[package]] +name = "bytecheck" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "bytecount" version = "0.6.8" @@ -747,9 +845,9 @@ dependencies = [ [[package]] name = "cargo-mobile2" -version = "0.17.0" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ede7b4200c8794c5fe7bc25c93a8f1756b87d50968cc20def67f2618035f65" +checksum = "a4200047e17fd50597ae9ee15657b0c53105394f95d3a1aa82148dba35acb412" dependencies = [ "colored", "core-foundation 0.10.0", @@ -982,6 +1080,22 @@ dependencies = [ "digest", ] +[[package]] +name = "cocoa" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c" +dependencies = [ + "bitflags 1.3.2", + "block", + "cocoa-foundation 0.1.2", + "core-foundation 0.9.4", + "core-graphics 0.23.2", + "foreign-types 0.5.0", + "libc", + "objc", +] + [[package]] name = "cocoa" version = "0.26.0" @@ -990,7 +1104,7 @@ checksum = "f79398230a6e2c08f5c9760610eb6924b52aa9e7950a619602baba59dcbbdbb2" dependencies = [ "bitflags 2.6.0", "block", - "cocoa-foundation", + "cocoa-foundation 0.2.0", "core-foundation 0.10.0", "core-graphics 0.24.0", "foreign-types 0.5.0", @@ -998,6 +1112,20 @@ dependencies = [ "objc", ] +[[package]] +name = "cocoa-foundation" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7" +dependencies = [ + "bitflags 1.3.2", + "block", + "core-foundation 0.9.4", + "core-graphics-types 0.1.3", + "libc", + "objc", +] + [[package]] name = "cocoa-foundation" version = "0.2.0" @@ -1949,6 +2077,15 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "fern" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9f0c14694cbd524c8720dd69b0e3179344f04ebb5f90f2e4a440c6ea3b2f1ee" +dependencies = [ + "log", +] + [[package]] name = "ff" version = "0.13.0" @@ -2130,6 +2267,12 @@ dependencies = [ "libc", ] +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futf" version = "0.1.5" @@ -2637,6 +2780,9 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.8", +] [[package]] name = "hashbrown" @@ -3434,7 +3580,7 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5f037c58cadb17e8591b620b523cc6a7ab2b91b6ce3121f8eb4171f8d80115c" dependencies = [ - "ahash", + "ahash 0.8.11", "anyhow", "base64 0.22.1", "bytecount", @@ -3946,7 +4092,7 @@ version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba8ac4080fb1e097c2c22acae467e46e4da72d941f02e82b67a87a2a89fa38b1" dependencies = [ - "cocoa", + "cocoa 0.26.0", "crossbeam-channel", "dpi", "gtk", @@ -4311,6 +4457,15 @@ dependencies = [ "syn 2.0.76", ] +[[package]] +name = "num_threads" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" +dependencies = [ + "libc", +] + [[package]] name = "objc" version = "0.2.7" @@ -5335,6 +5490,26 @@ dependencies = [ "unarray", ] +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "qoi" version = "0.4.1" @@ -5444,6 +5619,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.7.3" @@ -5673,6 +5854,15 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +[[package]] +name = "rend" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +dependencies = [ + "bytecheck", +] + [[package]] name = "reqwest" version = "0.12.7" @@ -5789,6 +5979,35 @@ dependencies = [ "digest", ] +[[package]] +name = "rkyv" +version = "0.7.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9008cd6385b9e161d8229e1f6549dd23c3d022f132a2ea37ac3a10ac4935779b" +dependencies = [ + "bitvec", + "bytecheck", + "bytes", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "503d1d27590a2b0a3a4ca4c94755aa2875657196ecbf401a42eff41d7de532c0" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "route-recognizer" version = "0.3.1" @@ -5872,6 +6091,22 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rust_decimal" +version = "1.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b082d80e3e3cc52b2ed634388d436fe1f4de6af5786cc2de9ba9737527bdf555" +dependencies = [ + "arrayvec", + "borsh", + "bytes", + "num-traits", + "rand 0.8.5", + "rkyv", + "serde", + "serde_json", +] + [[package]] name = "rustc-demangle" version = "0.1.24" @@ -6094,6 +6329,12 @@ version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0495e4577c672de8254beb68d01a9b62d0e8a13c099edecdbedccce3223cd29f" +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + [[package]] name = "sec1" version = "0.7.3" @@ -6504,6 +6745,12 @@ dependencies = [ "quote", ] +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + [[package]] name = "similar" version = "2.6.0" @@ -6896,6 +7143,18 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "sync_wrapper" version = "0.1.2" @@ -6944,7 +7203,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a93f2c6b8fdaeb7f417bda89b5bc767999745c3052969664ae1fa65892deb7e" dependencies = [ "bitflags 2.6.0", - "cocoa", + "cocoa 0.26.0", "core-foundation 0.10.0", "core-graphics 0.24.0", "crossbeam-channel", @@ -6987,6 +7246,12 @@ dependencies = [ "syn 2.0.76", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "tar" version = "0.4.41" @@ -7011,7 +7276,7 @@ dependencies = [ "anyhow", "bytes", "cargo_toml", - "cocoa", + "cocoa 0.26.0", "data-url", "dirs", "dunce", @@ -7325,6 +7590,45 @@ dependencies = [ "walkdir", ] +[[package]] +name = "tauri-plugin" +version = "2.0.0-rc.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad2b0b4fe684059a1b700c1a0d7d51698c05b2257ca64eca2a730d7be2e47c6a" +dependencies = [ + "anyhow", + "glob", + "plist", + "schemars", + "serde", + "serde_json", + "tauri-utils 2.0.0-rc.10 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.8.19", + "walkdir", +] + +[[package]] +name = "tauri-plugin-log" +version = "2.0.0-rc.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b57e4666c4a5d81f81b7bb8eacf51ae32c4e69c35071aabb480ad20a80836e4e" +dependencies = [ + "android_logger", + "byte-unit", + "cocoa 0.25.0", + "fern", + "log", + "objc", + "serde", + "serde_json", + "serde_repr", + "swift-rs", + "tauri", + "tauri-plugin 2.0.0-rc.10 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror", + "time", +] + [[package]] name = "tauri-plugin-sample" version = "0.1.0" @@ -7332,7 +7636,7 @@ dependencies = [ "log", "serde", "tauri", - "tauri-plugin", + "tauri-plugin 2.0.0-rc.10", "thiserror", ] @@ -7357,7 +7661,7 @@ dependencies = [ name = "tauri-runtime-wry" version = "2.0.0-rc.10" dependencies = [ - "cocoa", + "cocoa 0.26.0", "gtk", "http 1.1.0", "jni", @@ -7456,6 +7760,39 @@ dependencies = [ "walkdir", ] +[[package]] +name = "tauri-utils" +version = "2.0.0-rc.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba92ad9cdf7658fefa29a7218dda0acead9400c021bbf9c3f88e98f5e3b9bbab" +dependencies = [ + "cargo_metadata", + "ctor", + "dunce", + "glob", + "html5ever", + "infer 0.16.0", + "json-patch 2.0.0", + "kuchikiki", + "log", + "memchr", + "phf 0.11.2", + "proc-macro2", + "quote", + "regex", + "schemars", + "semver", + "serde", + "serde-untagged", + "serde_json", + "serde_with", + "swift-rs", + "thiserror", + "toml 0.8.19", + "url", + "urlpattern", +] + [[package]] name = "tauri-winres" version = "0.1.1" @@ -7578,7 +7915,9 @@ checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa 1.0.11", + "libc", "num-conv", + "num_threads", "powerfmt", "serde", "time-core", @@ -8208,6 +8547,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf8-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" + [[package]] name = "utf8parse" version = "0.2.2" @@ -8607,7 +8952,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8cdd6999298d969289d8078dae02ce798ad23452075985cccba8b6326711ecf" dependencies = [ - "cocoa", + "cocoa 0.26.0", "objc", "raw-window-handle", "windows-sys 0.59.0", @@ -8972,7 +9317,7 @@ checksum = "f4d715cf5fe88e9647f3d17b207b6d060d4a88e7171d4ccb2d2c657dd1d44728" dependencies = [ "base64 0.22.1", "block", - "cocoa", + "cocoa 0.26.0", "core-graphics 0.24.0", "crossbeam-channel", "dpi", @@ -9005,6 +9350,15 @@ dependencies = [ "x11-dl", ] +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "x11" version = "2.21.0" diff --git a/Cargo.toml b/Cargo.toml index 97766b5ac..8737954c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,3 +66,4 @@ opt-level = "s" # See https://github.com/GREsau/schemars/issues/120 for reference [patch.crates-io] schemars_derive = { git = 'https://github.com/tauri-apps/schemars.git', branch = 'feat/preserve-description-newlines' } +tauri = { path = "./crates/tauri" } diff --git a/crates/tauri-cli/Cargo.toml b/crates/tauri-cli/Cargo.toml index 05a075e18..e5fdf81fe 100644 --- a/crates/tauri-cli/Cargo.toml +++ b/crates/tauri-cli/Cargo.toml @@ -36,7 +36,7 @@ name = "cargo-tauri" path = "src/main.rs" [target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"windows\", target_os = \"macos\"))".dependencies] -cargo-mobile2 = { version = "0.17", default-features = false } +cargo-mobile2 = { version = "0.17.2", default-features = false } [dependencies] jsonrpsee = { version = "0.24", features = ["server"] } diff --git a/crates/tauri-cli/src/mobile/ios/build.rs b/crates/tauri-cli/src/mobile/ios/build.rs index 4eacfa72c..e459f801f 100644 --- a/crates/tauri-cli/src/mobile/ios/build.rs +++ b/crates/tauri-cli/src/mobile/ios/build.rs @@ -314,13 +314,7 @@ fn run_build( build_config = build_config.authentication_credentials(credentials.clone()); } - target.build( - config, - env, - NoiseLevel::FranklyQuitePedantic, - profile, - build_config, - )?; + target.build(config, env, noise_level, profile, build_config)?; target.archive( config, diff --git a/crates/tauri-cli/src/mobile/ios/dev.rs b/crates/tauri-cli/src/mobile/ios/dev.rs index 1814f499f..a488f9b6e 100644 --- a/crates/tauri-cli/src/mobile/ios/dev.rs +++ b/crates/tauri-cli/src/mobile/ios/dev.rs @@ -417,7 +417,7 @@ fn run_dev( } open_and_wait(config, &env) } else if let Some(device) = &device { - match run(device, options, config, &env) { + match run(device, options, config, noise_level, &env) { Ok(c) => Ok(Box::new(c) as Box), Err(e) => { crate::dev::kill_before_dev_process(); @@ -438,6 +438,7 @@ fn run( device: &Device<'_>, options: MobileOptions, config: &AppleConfig, + noise_level: NoiseLevel, env: &Env, ) -> crate::Result { let profile = if options.debug { @@ -450,7 +451,7 @@ fn run( .run( config, env, - NoiseLevel::FranklyQuitePedantic, + noise_level, false, // do not quit on app exit profile, ) diff --git a/examples/api/src-tauri/Cargo.toml b/examples/api/src-tauri/Cargo.toml index 588d7dc45..6f486f821 100644 --- a/examples/api/src-tauri/Cargo.toml +++ b/examples/api/src-tauri/Cargo.toml @@ -22,6 +22,7 @@ serde = { version = "1.0", features = ["derive"] } tiny_http = "0.11" log = "0.4" tauri-plugin-sample = { path = "./tauri-plugin-sample/" } +tauri-plugin-log = "2.0.0-rc" [dependencies.tauri] path = "../../../crates/tauri" diff --git a/examples/api/src-tauri/src/lib.rs b/examples/api/src-tauri/src/lib.rs index 743fd285c..512f43c0a 100644 --- a/examples/api/src-tauri/src/lib.rs +++ b/examples/api/src-tauri/src/lib.rs @@ -40,6 +40,11 @@ pub fn run_app) + Send + 'static>( ) { #[allow(unused_mut)] let mut builder = builder + .plugin( + tauri_plugin_log::Builder::default() + .level(log::LevelFilter::Info) + .build(), + ) .plugin(tauri_plugin_sample::init()) .setup(move |app| { #[cfg(all(desktop, not(test)))]