From 4d2ec2e148f5205cf018f0eb854113d9d8b380b3 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Wed, 31 May 2023 15:44:35 -0400 Subject: [PATCH] feat: Make updater build on iOS (#22) Doesn't work yet, but does at least build (and log). --- BUILDING_ENGINE.md | 11 +++++++++++ library/Cargo.toml | 5 +++++ library/src/config.rs | 2 ++ library/src/logging.rs | 15 ++++++++++++--- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/BUILDING_ENGINE.md b/BUILDING_ENGINE.md index 8050e2b..e4363c0 100644 --- a/BUILDING_ENGINE.md +++ b/BUILDING_ENGINE.md @@ -134,3 +134,14 @@ When testing on my machine, I use something like: $PATH_TO_ENGINE_SRC="$HOME/Documents/GitHub/engine/src" shorebird --local-engine-src-path=$PATH_TO_ENGINE_SRC --local-engine=android_release_arm64 run ``` + + +# For iOS + +``` +rustup target add aarch64-apple-ios x86_64-apple-ios +``` + +``` +cargo build --target aarch64-apple-ios --target x86_64-apple-ios --release +``` \ No newline at end of file diff --git a/library/Cargo.toml b/library/Cargo.toml index 9f4312b..b0dadd7 100644 --- a/library/Cargo.toml +++ b/library/Cargo.toml @@ -48,6 +48,11 @@ android_logger = "0.13.0" # Send panics to log (instead of stderr), thus logcat on Android. log-panics = { version = "2", features = ["with-backtrace"]} +[target.'cfg(target_os = "ios")'.dependencies] +# Use stderr for logging on iOS. +simple-logging = "2.0.2" +# Send panics to syslog (instead of stderr). +log-panics = { version = "2", features = ["with-backtrace"]} [dev-dependencies] tempdir = "0.3.7" diff --git a/library/src/config.rs b/library/src/config.rs index 7ef1508..9663814 100644 --- a/library/src/config.rs +++ b/library/src/config.rs @@ -220,5 +220,7 @@ pub fn current_platform() -> &'static str { static PLATFORM: &str = "windows"; #[cfg(target_os = "android")] static PLATFORM: &str = "android"; + #[cfg(target_os = "ios")] + static PLATFORM: &str = "ios"; return PLATFORM; } diff --git a/library/src/logging.rs b/library/src/logging.rs index b4cc6d8..fe6efbc 100644 --- a/library/src/logging.rs +++ b/library/src/logging.rs @@ -11,8 +11,17 @@ pub fn init_logging() { debug!("Logging initialized"); } -#[cfg(not(target_os = "android"))] +#[cfg(target_os = "ios")] pub fn init_logging() { - // Nothing to do on non-Android platforms. - // Eventually iOS/MacOS may need something here. + // I could not figure out how to get fancier logging set up on iOS + // but logging to stderr seems to work. + use log::LevelFilter; + use std::io; + simple_logging::log_to(io::stderr(), LevelFilter::Info); + debug!("Logging initialized"); +} + +#[cfg(all(not(target_os = "android"), not(target_os = "ios")))] +pub fn init_logging() { + // Nothing to do on non-Android, non-iOS platforms. }