mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: support building on iOS platform (#3033)
This commit is contained in:
96
frontend/scripts/install_dev_env/install_ios.sh
Normal file
96
frontend/scripts/install_dev_env/install_ios.sh
Normal file
@ -0,0 +1,96 @@
|
||||
#!/bin/bash
|
||||
|
||||
YELLOW="\e[93m"
|
||||
GREEN="\e[32m"
|
||||
RED="\e[31m"
|
||||
ENDCOLOR="\e[0m"
|
||||
|
||||
printMessage() {
|
||||
printf "${YELLOW}AppFlowy : $1${ENDCOLOR}\n"
|
||||
}
|
||||
|
||||
printSuccess() {
|
||||
printf "${GREEN}AppFlowy : $1${ENDCOLOR}\n"
|
||||
}
|
||||
|
||||
printError() {
|
||||
printf "${RED}AppFlowy : $1${ENDCOLOR}\n"
|
||||
}
|
||||
|
||||
# Install Rust
|
||||
printMessage "The Rust programming language is required to compile AppFlowy."
|
||||
printMessage "We can install it now if you don't already have it on your system."
|
||||
|
||||
read -p "$(printSuccess "Do you want to install Rust? [y/N]") " installrust
|
||||
|
||||
if [[ "${installrust:-N}" == [Yy] ]]; then
|
||||
printMessage "Installing Rust."
|
||||
brew install rustup-init
|
||||
rustup-init -y --default-toolchain=stable
|
||||
|
||||
source "$HOME/.cargo/env"
|
||||
else
|
||||
printMessage "Skipping Rust installation."
|
||||
fi
|
||||
|
||||
rustup target add aarch64-apple-ios
|
||||
rustup target add aarch64-apple-ios-sim
|
||||
|
||||
# Install sqllite
|
||||
printMessage "Installing sqlLite3."
|
||||
brew install sqlite3
|
||||
|
||||
printMessage "Setting up Flutter"
|
||||
|
||||
# Get the current Flutter version
|
||||
FLUTTER_VERSION=$(flutter --version | grep -oE 'Flutter [^ ]+' | grep -oE '[^ ]+$')
|
||||
# Check if the current version is 3.10.1
|
||||
if [ "$FLUTTER_VERSION" = "3.10.1" ]; then
|
||||
echo "Flutter version is already 3.10.1"
|
||||
else
|
||||
# Get the path to the Flutter SDK
|
||||
FLUTTER_PATH=$(which flutter)
|
||||
FLUTTER_PATH=${FLUTTER_PATH%/bin/flutter}
|
||||
|
||||
current_dir=$(pwd)
|
||||
|
||||
cd $FLUTTER_PATH
|
||||
# Use git to checkout version 3.10.1 of Flutter
|
||||
git checkout 3.10.1
|
||||
# Get back to current working directory
|
||||
cd "$current_dir"
|
||||
|
||||
echo "Switched to Flutter version 3.10.1"
|
||||
fi
|
||||
|
||||
# Enable linux desktop
|
||||
flutter config --enable-macos-desktop
|
||||
|
||||
# Fix any problems reported by flutter doctor
|
||||
flutter doctor
|
||||
|
||||
# Add the githooks directory to your git configuration
|
||||
printMessage "Setting up githooks."
|
||||
git config core.hooksPath .githooks
|
||||
|
||||
# Install go-gitlint
|
||||
printMessage "Installing go-gitlint."
|
||||
GOLINT_FILENAME="go-gitlint_1.1.0_osx_x86_64.tar.gz"
|
||||
curl -L https://github.com/llorllale/go-gitlint/releases/download/1.1.0/${GOLINT_FILENAME} --output ${GOLINT_FILENAME}
|
||||
tar -zxv --directory .githooks/. -f ${GOLINT_FILENAME} gitlint
|
||||
rm ${GOLINT_FILENAME}
|
||||
|
||||
# Change to the frontend directory
|
||||
cd frontend || exit 1
|
||||
|
||||
# Install cargo make
|
||||
printMessage "Installing cargo-make."
|
||||
cargo install --force cargo-make
|
||||
|
||||
# Install duckscript
|
||||
printMessage "Installing duckscript."
|
||||
cargo install --force duckscript_cli
|
||||
|
||||
# Check prerequisites
|
||||
printMessage "Checking prerequisites."
|
||||
cargo make appflowy-flutter-deps-tools
|
@ -38,6 +38,15 @@ mac_alias = "appflowy-macos-dev"
|
||||
windows_alias = "appflowy-windows-dev"
|
||||
linux_alias = "appflowy-linux-dev"
|
||||
|
||||
[tasks.appflowy-ios-dev]
|
||||
dependencies = ["appflowy-core-dev-ios"]
|
||||
run_task = { name = [
|
||||
"code_generation",
|
||||
"set-app-version",
|
||||
"flutter-build",
|
||||
] }
|
||||
script_runner = "@shell"
|
||||
|
||||
[tasks.appflowy-macos-dev]
|
||||
dependencies = ["appflowy-core-dev"]
|
||||
run_task = { name = [
|
||||
|
55
frontend/scripts/makefile/mobile.toml
Normal file
55
frontend/scripts/makefile/mobile.toml
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
[tasks.env_check]
|
||||
dependencies = ["echo_env", "install_flutter_protobuf"]
|
||||
condition = { env_set = [
|
||||
"BUILD_FLAG",
|
||||
"RUST_COMPILE_TARGET",
|
||||
"CRATE_TYPE",
|
||||
"TARGET_OS",
|
||||
], channels = [
|
||||
"stable",
|
||||
] }
|
||||
|
||||
[tasks.appflowy-core-dev-ios]
|
||||
category = "Build"
|
||||
dependencies = ["env_check"]
|
||||
run_task = { name = [
|
||||
"setup-crate-type",
|
||||
"sdk-build-ios",
|
||||
"post-mobile-ios",
|
||||
"restore-crate-type",
|
||||
] }
|
||||
|
||||
[tasks.sdk-build-ios]
|
||||
private = true
|
||||
script = [
|
||||
"""
|
||||
cd rust-lib/
|
||||
rustup show
|
||||
echo cargo lipo --targets ${RUST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}"
|
||||
cargo lipo --targets ${RUST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}"
|
||||
cd ../
|
||||
""",
|
||||
]
|
||||
script_runner = "@shell"
|
||||
|
||||
[tasks.post-mobile-ios]
|
||||
private = true
|
||||
script = [
|
||||
"""
|
||||
echo "🚀 🚀 🚀 AppFlowy-Core for iOS platform build success"
|
||||
dart_ffi_dir= set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/appflowy_flutter/packages/appflowy_backend/${TARGET_OS}
|
||||
lib = set lib${LIB_NAME}.${LIB_EXT}
|
||||
|
||||
echo "💻 💻 💻 Copying ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/${lib} to ${dart_ffi_dir}/${lib}"
|
||||
rm -f ${dart_ffi_dir}/${lib}
|
||||
cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/${lib} \
|
||||
${dart_ffi_dir}/${lib}
|
||||
|
||||
echo "💻 💻 💻 Copying ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/binding.h to ${dart_ffi_dir}/Classes/binding.h"
|
||||
rm -f ${dart_ffi_dir}/Classes/binding.h
|
||||
cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/binding.h \
|
||||
${dart_ffi_dir}/Classes/binding.h
|
||||
""",
|
||||
]
|
||||
script_runner = "@duckscript"
|
Reference in New Issue
Block a user