From 51cec15ecea8906b63a2f95be72f8bc17ad6f9b0 Mon Sep 17 00:00:00 2001 From: Linus Gasser Date: Mon, 3 May 2021 11:14:42 +0200 Subject: [PATCH] Add information for rust-bitcode The installation instructions were missing for the iOS part. Also some of the import parts in the xcode project were wrong. --- README.md | 18 ++++++++++++++++-- ios_app/build-rust-xcode.sh | 4 ++-- ios_app/ios_app.xcodeproj/project.pbxproj | 9 ++++++--- .../xcshareddata/xcschemes/ios_app.xcscheme | 2 +- .../xcschemes/ios_appTests.xcscheme | 2 +- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f7704a7..c0923ca 100644 --- a/README.md +++ b/README.md @@ -106,12 +106,26 @@ rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-and ## iOS specific steps -- Add targets +- Install rust 1.46.0 with MacOSX binary support ``` -rustup target add x86_64-apple-ios aarch64-apple-ios +wget https://github.com/getditto/rust-bitcode/releases/download/v1.46.0/rust-ios-arm64-1.46.0.zip +unzip rust-ios-arm64-1.46.0.zip +cd rust-ios-arm64-1.46.0 +./install.sh ``` +As the binaries are not signed, you'll have to convince MacOSX that it's safe to run them. +One solution is to do the following: + +1. `cd rust_android_ios/ios_app` +2. `cargo +ios-arm64-1.46.0 build --target aarch64-apple-ios --release --lib` +3.a. if it fails because MacOSX doesn't trust the binary, go to + `System Preferences -> Security & Privacy` and `Allow to run binary` + then go to 2. +3.b. if it fails with another error, ask Google +3.c. if it compiles, go on + - Run the project in Xcode. This will build Rust, put the binaries in the correct place and start the app. ## Android specifics diff --git a/ios_app/build-rust-xcode.sh b/ios_app/build-rust-xcode.sh index 30396ab..f2bc041 100644 --- a/ios_app/build-rust-xcode.sh +++ b/ios_app/build-rust-xcode.sh @@ -1,7 +1,7 @@ #!/bin/bash # Ensure that `cargo` is in PATH, using the default location. -export PATH="$PATH:${HOME}/.cargo/bin" +. "$HOME/.cargo/env" set -x @@ -9,7 +9,7 @@ set -x cd "${SRCROOT}/../" # Build binaries -RUSTFLAGS="-Z embed-bitcode" cargo +ios-arm64 build --target aarch64-apple-ios --release --lib +cargo +ios-arm64-1.46.0 build --target aarch64-apple-ios --release --lib cargo build --target=x86_64-apple-ios --release # Create fat binary diff --git a/ios_app/ios_app.xcodeproj/project.pbxproj b/ios_app/ios_app.xcodeproj/project.pbxproj index b965781..737031f 100644 --- a/ios_app/ios_app.xcodeproj/project.pbxproj +++ b/ios_app/ios_app.xcodeproj/project.pbxproj @@ -206,7 +206,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1030; - LastUpgradeCheck = 1030; + LastUpgradeCheck = 1250; ORGANIZATIONNAME = com.schuetz; TargetAttributes = { 84B0671E22F9B3FE006DDC18 = { @@ -340,6 +340,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -401,6 +402,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -448,7 +450,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "com.schuetz.ios-app"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "/Users/ischuetz/dev/rust/rust_android_ios/ios_app/Rust-Bridging-Header.h"; + SWIFT_OBJC_BRIDGING_HEADER = "Rust-Bridging-Header.h"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -470,9 +472,10 @@ "$(PROJECT_DIR)", "$(PROJECT_DIR)/core", ); + ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.schuetz.ios-app"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "/Users/ischuetz/dev/rust/rust_android_ios/ios_app/Rust-Bridging-Header.h"; + SWIFT_OBJC_BRIDGING_HEADER = "Rust-Bridging-Header.h"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; diff --git a/ios_app/ios_app.xcodeproj/xcshareddata/xcschemes/ios_app.xcscheme b/ios_app/ios_app.xcodeproj/xcshareddata/xcschemes/ios_app.xcscheme index 6d8c871..41c9d7b 100644 --- a/ios_app/ios_app.xcodeproj/xcshareddata/xcschemes/ios_app.xcscheme +++ b/ios_app/ios_app.xcodeproj/xcshareddata/xcschemes/ios_app.xcscheme @@ -1,6 +1,6 @@