Skip to content

Commit

Permalink
feat: Make updater build on iOS (#22)
Browse files Browse the repository at this point in the history
Doesn't work yet, but does at least build (and log).
  • Loading branch information
eseidel authored May 31, 2023
1 parent 11d8c22 commit 4d2ec2e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
11 changes: 11 additions & 0 deletions BUILDING_ENGINE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
5 changes: 5 additions & 0 deletions library/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions library/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
15 changes: 12 additions & 3 deletions library/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}

0 comments on commit 4d2ec2e

Please sign in to comment.