From 4bca4e5b23197bdbaecc1b559472159912430610 Mon Sep 17 00:00:00 2001 From: Akhash S Date: Sat, 9 Aug 2025 20:58:56 -0700 Subject: [PATCH 1/3] fix: Add Windows support for Android builds and centralize documentation - Add Windows-compatible build scripts for Android using duckscript - Update Android README with Windows-specific NDK configuration - Create comprehensive BUILD_FROM_SOURCE.md documentation - Update main README and Flutter README to reference centralized docs - Split Android build tasks into platform-specific variants Fixes #5336: Build for Android on Windows + Documentation update --- .history/README_20250809205828.md | 158 +++++++++++++ .../doc/BUILD_FROM_SOURCE_20250809205822.md | 219 ++++++++++++++++++ .../appflowy_flutter/README_20250809205836.md | 54 +++++ .../android/README_20250809205701.md | 76 ++++++ .../android/README_20250809205722.md | 96 ++++++++ .../android/README_20250809205734.md | 100 ++++++++ .../android/README_20250809205743.md | 119 ++++++++++ .../makefile/mobile_20250809205646.toml | 171 ++++++++++++++ .../makefile/mobile_20250809205653.toml | 188 +++++++++++++++ README.md | 5 +- doc/BUILD_FROM_SOURCE.md | 219 ++++++++++++++++++ frontend/appflowy_flutter/.metadata | 14 +- frontend/appflowy_flutter/README.md | 6 +- frontend/appflowy_flutter/android/README.md | 95 ++++++-- .../io/appflowy/appflowy/MainActivity.kt | 5 + .../main/res/drawable/launch_background.xml | 12 + frontend/scripts/makefile/mobile.toml | 40 ++++ 17 files changed, 1547 insertions(+), 30 deletions(-) create mode 100644 .history/README_20250809205828.md create mode 100644 .history/doc/BUILD_FROM_SOURCE_20250809205822.md create mode 100644 .history/frontend/appflowy_flutter/README_20250809205836.md create mode 100644 .history/frontend/appflowy_flutter/android/README_20250809205701.md create mode 100644 .history/frontend/appflowy_flutter/android/README_20250809205722.md create mode 100644 .history/frontend/appflowy_flutter/android/README_20250809205734.md create mode 100644 .history/frontend/appflowy_flutter/android/README_20250809205743.md create mode 100644 .history/frontend/scripts/makefile/mobile_20250809205646.toml create mode 100644 .history/frontend/scripts/makefile/mobile_20250809205653.toml create mode 100644 doc/BUILD_FROM_SOURCE.md create mode 100644 frontend/appflowy_flutter/android/app/src/main/kotlin/io/appflowy/appflowy/MainActivity.kt create mode 100644 frontend/appflowy_flutter/android/app/src/main/res/drawable/launch_background.xml diff --git a/.history/README_20250809205828.md b/.history/README_20250809205828.md new file mode 100644 index 0000000000000..c85d798a76225 --- /dev/null +++ b/.history/README_20250809205828.md @@ -0,0 +1,158 @@ +

+ + AppFlowy
+
+ ⭐️ The Open Source Alternative To Notion ⭐️
+

+ +

+AppFlowy is the AI workspace where you achieve more without losing control of your data +

+ +

+ + + +License: AGPL + +

+ +

+ Website • + Forum • + Discord • + Reddit • + Twitter +

+ +

AppFlowy Kanban Board for To-dos

+

AppFlowy Databases for Tasks and Projects

+

AppFlowy Sites for Beautiful documentation

+

AppFlowy AI

+

AppFlowy Templates

+ +

+

+ Work across devices

+

+ Work across devices

+

+ Work across devices

+ +## User Installation + +- [Download AppFlowy Desktop (macOS, Windows, and Linux)](https://github.com/AppFlowy-IO/AppFlowy/releases) +- Other + channels: [FlatHub](https://flathub.org/apps/io.appflowy.AppFlowy), [Snapcraft](https://snapcraft.io/appflowy), [Sourceforge](https://sourceforge.net/projects/appflowy/) +- Available on + - [App Store](https://apps.apple.com/app/appflowy/id6457261352): iPhone + - [Play Store](https://play.google.com/store/apps/details?id=io.appflowy.appflowy): Android 10 or above; ARMv7 is + not supported +- [Self-hosting AppFlowy](https://appflowy.com/docs/self-host-appflowy-overview) +- [Source](https://docs.appflowy.io/docs/documentation/appflowy/from-source) + +## Built With + +- [Flutter](https://flutter.dev/) + +- [Rust](https://www.rust-lang.org/) + +## Stay Up-to-Date + +

AppFlowy Github - how to star the repo

+ +## Getting Started with development + +Please view our comprehensive [build from source guide](doc/BUILD_FROM_SOURCE.md) for detailed OS-specific development instructions, including desktop and mobile platform support. + +For additional documentation, visit [docs.appflowy.io](https://docs.appflowy.io/docs/documentation/appflowy/from-source). + +## Roadmap + +- [AppFlowy Roadmap ReadMe](https://docs.appflowy.io/docs/appflowy/roadmap) +- [AppFlowy Public Roadmap](https://github.com/orgs/AppFlowy-IO/projects/5/views/12) + +If you'd like to propose a feature, submit a feature +request [here](https://github.com/AppFlowy-IO/AppFlowy/issues/new?assignees=&labels=&template=feature_request.yaml&title=%5BFR%5D+)
+If you'd like to report a bug, submit a bug +report [here](https://github.com/AppFlowy-IO/AppFlowy/issues/new?assignees=&labels=&template=bug_report.yaml&title=%5BBug%5D+) + +## **Releases** + +Please see the [changelog](https://appflowy.com/what-is-new) for more details about a given release. + +## Contributing + +Contributions make the open-source community a fantastic place to learn, inspire, and create. Any contributions you make +are **greatly appreciated**. Please look +at [Contributing to AppFlowy](https://docs.appflowy.io/docs/documentation/software-contributions/contributing-to-appflowy) +for details. + +If your Pull Request is accepted as it fixes a bug, adds functionality, or makes AppFlowy's codebase significantly +easier to use or understand, **Congratulations!** If your administrative and managerial work behind the scenes sustains +the community, **Congratulations!** You are now an official contributor to AppFlowy. + +## Translations 🌎🗺 + +[![translation badge](https://inlang.com/badge?url=github.com/AppFlowy-IO/AppFlowy)](https://inlang.com/editor/github.com/AppFlowy-IO/AppFlowy?ref=badge) + +To add translations, you can manually edit the JSON translation files in `/frontend/resources/translations`, use +the [inlang online editor](https://inlang.com/editor/github.com/AppFlowy-IO/AppFlowy), or +run `npx inlang machine translate` to add missing translations. + +## Join the community to build AppFlowy together + + + + + +## Why Are We Building This? + +Notion has been our favourite project and knowledge management tool in recent years because of its aesthetic appeal and +functionality. Our team uses it daily, and we are on its paid plan. However, as we all know, Notion has its limitations. +These include weak data security and poor compatibility with mobile devices. Likewise, alternative collaborative +workplace management tools also have their constraints. + +The limitations we encountered using these tools and our past work experience with collaborative productivity tools have +led to our firm belief that there is a glass ceiling on what's possible for these tools in the future. This emanates +from the fact that these tools will probably struggle to scale horizontally at some point and be forced to prioritize a +proportion of customers whose needs differ from the rest. While decision-makers want a workplace OS, it is impossible to +come up with a one-size fits all solution in such a fragmented market. + +When a customer's evolving core needs are not satisfied, they either switch to another or build one from the ground up, +in-house. Consequently, they either go under another ceiling or buy an expensive ticket to learn a hard lesson. This is +a requirement for many resources and expertise, building a reliable and easy-to-use collaborative tool, not to mention +the speed and native experience. The same may apply to individual users as well. + +All these restrictions necessitate our mission - to make it possible for anyone to create apps that suit their needs +well. + +- To individuals, we would like to offer Notion's functionality, data security, and cross-platform native experience. +- To enterprises and hackers, AppFlowy is dedicated to offering building blocks and collaboration infra services to + enable you to make apps on your own. Moreover, you have 100% control of your data. You can design and modify AppFlowy + your way, with a single codebase written in Flutter and Rust supporting multiple platforms armed with long-term + maintainability. + +We decided to achieve this mission by upholding the three most fundamental values: + +- Data privacy first +- Reliable native experience +- Community-driven extensibility + +We do not claim to outperform Notion in terms of functionality and design, at least for now. Besides, our priority +doesn't lie in more functionality at the moment. Instead, we would like to cultivate a community to democratize the +knowledge and wheels of making complex workplace management tools while enabling people and businesses to create +beautiful things on their own by equipping them with a versatile toolbox of building blocks. + +## License + +Distributed under the AGPLv3 License. See [`LICENSE.md`](https://github.com/AppFlowy-IO/AppFlowy/blob/main/LICENSE) for +more information. + +## Acknowledgments + +Special thanks to these amazing projects which help power AppFlowy: + +- [cargo-make](https://github.com/sagiegurari/cargo-make) +- [contrib.rocks](https://contrib.rocks) +- [flutter_chat_ui](https://pub.dev/packages/flutter_chat_ui) diff --git a/.history/doc/BUILD_FROM_SOURCE_20250809205822.md b/.history/doc/BUILD_FROM_SOURCE_20250809205822.md new file mode 100644 index 0000000000000..dcc17beb3d72e --- /dev/null +++ b/.history/doc/BUILD_FROM_SOURCE_20250809205822.md @@ -0,0 +1,219 @@ +# Building AppFlowy from Source + +This guide provides comprehensive instructions for building AppFlowy from source code on all supported platforms. + +## Prerequisites + +Before building AppFlowy, ensure you have the following installed: + +### All Platforms +- [Git](https://git-scm.com/) +- [Rust](https://rustup.rs/) (1.70 or later) +- [Flutter](https://flutter.dev/docs/get-started/install) (3.13.19 or later) +- [cargo-make](https://github.com/sagiegurari/cargo-make) - Install with: `cargo install cargo-make` + +### Platform-Specific Requirements + +#### Windows +- [Visual Studio 2019/2022](https://visualstudio.microsoft.com/) with C++ development tools +- [vcpkg](https://github.com/microsoft/vcpkg) + +#### macOS +- Xcode Command Line Tools: `xcode-select --install` + +#### Linux +- Build essentials: `sudo apt install build-essential pkg-config libssl-dev` +- Additional dependencies: `sudo apt install clang cmake ninja-build pkg-config libgtk-3-dev` + +## Building for Desktop + +### 1. Clone the Repository +```bash +git clone https://github.com/AppFlowy-IO/AppFlowy.git +cd AppFlowy +``` + +### 2. Build for Your Platform + +#### Windows +```bash +cd frontend +cargo make appflowy-windows +``` + +#### macOS +```bash +cd frontend +cargo make appflowy-macos +``` + +#### Linux +```bash +cd frontend +cargo make appflowy-linux +``` + +### 3. Run the Application + +After building, the executable will be located in: +- **Windows**: `frontend/appflowy_flutter/product/[version]/windows/Release/AppFlowy/` +- **macOS**: `frontend/appflowy_flutter/product/[version]/macos/Release/AppFlowy.app/` +- **Linux**: `frontend/appflowy_flutter/product/[version]/linux/Release/AppFlowy/` + +## Building for Mobile + +### iOS + +#### Prerequisites +- macOS with Xcode installed +- iOS development setup for Flutter + +#### Build Steps +```bash +cd frontend +cargo make appflowy-ios +``` + +The iOS app will be built and available in `frontend/appflowy_flutter/build/ios/`. + +### Android + +#### Prerequisites + +**All Platforms:** +- [Android NDK](https://developer.android.com/ndk/downloads/) version 24 +- cargo-ndk: `cargo install cargo-ndk` + +**Additional Setup:** + +1. **Set Environment Variables** + + **Windows:** + ```cmd + set ANDROID_NDK_HOME=C:\Users\%USERNAME%\AppData\Local\Android\Sdk\ndk\24.0.8215888 + ``` + + **macOS/Linux:** + ```bash + export ANDROID_NDK_HOME=~/Android/Sdk/ndk/24.0.8215888 + ``` + +2. **Configure Cargo for Android** + + Create or edit `~/.cargo/config` (Linux/macOS) or `%USERPROFILE%\.cargo\config` (Windows): + + **Linux/macOS:** + ```toml + [target.aarch64-linux-android] + ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" + linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang" + + [target.armv7-linux-androideabi] + ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" + linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi29-clang" + + [target.i686-linux-android] + ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" + linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android29-clang" + + [target.x86_64-linux-android] + ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" + linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android29-clang" + ``` + + **Windows:** + ```toml + [target.aarch64-linux-android] + ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" + linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\aarch64-linux-android29-clang.exe" + + [target.armv7-linux-androideabi] + ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" + linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\armv7a-linux-androideabi29-clang.exe" + + [target.i686-linux-android] + ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" + linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\i686-linux-android29-clang.exe" + + [target.x86_64-linux-android] + ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" + linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\x86_64-linux-android29-clang.exe" + ``` + +3. **NDK 24 Clang Fix** + + Create a file named `libgcc.a` with this content: + ``` + INPUT(-lunwind) + ``` + + **Linux/macOS:** Place it in `Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux/` + + **Windows:** Place it in `Android\Sdk\ndk\24.0.8215888\toolchains\llvm\prebuilt\windows-x86_64\lib64\clang\14.0.1\lib\linux\` + + Copy this file to the following subdirectories: `aarch64`, `arm`, `i386`, and `x86_64`. + +#### Build Steps +```bash +cd frontend +cargo make appflowy-android +``` + +The Android APK will be built and available in `frontend/appflowy_flutter/build/app/outputs/flutter-apk/`. + +## Development Builds + +For faster development builds without optimizations: + +### Desktop Development +```bash +cd frontend +cargo make appflowy-dev # Uses platform-specific aliases +``` + +### Mobile Development +```bash +# iOS development build +cd frontend +cargo make appflowy-ios-dev + +# Android development build +cd frontend +cargo make appflowy-android-dev +``` + +## Troubleshooting + +### Common Issues + +1. **Flutter Doctor Issues**: Run `flutter doctor` to check for missing dependencies +2. **Rust Version**: Ensure you're using Rust 1.70 or later +3. **Path Issues**: Make sure all tools are in your system PATH +4. **NDK Issues**: Verify ANDROID_NDK_HOME is set correctly + +### Platform-Specific Issues + +#### Windows +- Ensure Visual Studio C++ tools are installed +- Check that vcpkg is properly configured +- Use PowerShell or Command Prompt, not Git Bash for building + +#### macOS +- Ensure Xcode Command Line Tools are installed +- For iOS builds, you need a full Xcode installation + +#### Linux +- Install all required system dependencies +- Check that pkg-config can find required libraries + +### Getting Help + +- Check the [AppFlowy Documentation](https://docs.appflowy.io/) +- Join our [Discord](https://discord.gg/9Q2xaN37tV) for community support +- Report issues on [GitHub](https://github.com/AppFlowy-IO/AppFlowy/issues) + +## Additional Resources + +- [AppFlowy Development Guide](https://docs.appflowy.io/docs/documentation/appflowy/from-source) +- [Contributing Guidelines](CONTRIBUTING.md) +- [Android-specific instructions](../frontend/appflowy_flutter/android/README.md) diff --git a/.history/frontend/appflowy_flutter/README_20250809205836.md b/.history/frontend/appflowy_flutter/README_20250809205836.md new file mode 100644 index 0000000000000..b8f224356417d --- /dev/null +++ b/.history/frontend/appflowy_flutter/README_20250809205836.md @@ -0,0 +1,54 @@ +

AppFlowy_Flutter

+
+ + +
+ +> Documentation for Contributors + +This Repository contains the codebase for the frontend of the application, currently we use Flutter as our frontend framework. + +### Platforms Supported Using Flutter 💻 + +- Linux +- macOS +- Windows + > We are actively working on support for Android & iOS! + +_Additionally, we are working on a Web version built with Tauri!_ + +### Am I Eligible to Contribute? + +Yes! You are eligible to contribute, check out the ways in which you can [contribute to AppFlowy](https://docs.appflowy.io/docs/documentation/software-contributions/contributing-to-appflowy). Some of the ways in which you can contribute are: + +- Non-Coding Contributions + - Documentation + - Feature Requests and Feedbacks + - Report Bugs + - Improve Translations +- Coding Contributions + +To contribute to `AppFlowy_Flutter` codebase specifically (coding contribution) we suggest you to have basic knowledge of Flutter. In case you are new to Flutter, we suggest you learn the basics, and then contribute afterwards. To get started with Flutter read [here](https://flutter.dev/docs/get-started/codelab). + +### What OS should I use for development? + +We support all OS for Development i.e. Linux, MacOS and Windows. We have detailed documentation on how to setup `AppFlowy_Flutter` on your local system for each operating system: + +- [Build from Source Guide](../../doc/BUILD_FROM_SOURCE.md) - Comprehensive setup instructions for all platforms +- [Android-specific Guide](android/README.md) - Detailed Android build instructions including Windows support +- [Online Documentation](https://docs.appflowy.io/docs/documentation/appflowy/from-source/environment-setup) - Additional setup resources + +### Getting Started ❇ + +We have detailed documentation on how to [get started](https://docs.appflowy.io/docs/documentation/software-contributions/contributing-to-appflowy) with the project, and make your first contribution. However, we do have some specific picks for you: + +- [Code Architecture](https://appflowy.gitbook.io/docs/essential-documentation/contribute-to-appflowy/architecture/frontend/frontend/codemap) +- [Styleguide & Conventions](https://docs.appflowy.io/docs/documentation/software-contributions/conventions/naming-conventions) +- [Making Your First PR](https://docs.appflowy.io/docs/documentation/software-contributions/submitting-code/submitting-your-first-pull-request) +- [All AppFlowy Documentation](https://docs.appflowy.io/docs/documentation/appflowy) - Contribution guide, build and run, debugging, testing, localization, etc. + +### Need Help? + +- New to GitHub? Follow [these](https://docs.appflowy.io/docs/documentation/software-contributions/submitting-code/setting-up-your-repositories) steps to get started +- Stuck Somewhere? Join our [Discord](https://discord.gg/9Q2xaN37tV), we're there to help you! +- Find out more about the [community initiatives](https://docs.appflowy.io/docs/appflowy/community). diff --git a/.history/frontend/appflowy_flutter/android/README_20250809205701.md b/.history/frontend/appflowy_flutter/android/README_20250809205701.md new file mode 100644 index 0000000000000..da9cf2b6f08c7 --- /dev/null +++ b/.history/frontend/appflowy_flutter/android/README_20250809205701.md @@ -0,0 +1,76 @@ +# Description + +This is a guide on how to build the rust SDK for AppFlowy on android. +Compiling the sdk is easy it just needs a few tweaks. +When compiling for android we need the following pre-requisites: + +- Android NDK Tools. (v24 has been tested). +- Cargo NDK. (@latest version). + +**Getting the tools** +- Install cargo-ndk ```bash cargo install cargo-ndk```. +- [Download](https://developer.android.com/ndk/downloads/) Android NDK version 24. +- When downloading Android NDK you can get the compressed version as a standalone from the site. + Or you can download it through [Android Studio](https://developer.android.com/studio). +- After downloading the two you need to set the environment variables. The process differs by operating system. +- The variables needed are '$ANDROID_NDK_HOME', this will point to where the NDK is located. + +**Setting Environment Variables** + +**Windows:** +```cmd +set ANDROID_NDK_HOME=C:\Users\%USERNAME%\AppData\Local\Android\Sdk\ndk\24.0.8215888 +``` +Or add to your system environment variables permanently. + +**macOS/Linux:** +```bash +export ANDROID_NDK_HOME=~/Android/Sdk/ndk/24.0.8215888 +``` +--- + +**Cargo Config File** +This code needs to be written in ~/.cargo/config, this helps cargo know where to locate the android tools(linker and archiver). +**NB** Keep in mind just replace 'user' with your own user name. Or just point it to the location of where you put the NDK. + +```toml +[target.aarch64-linux-android] +ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" +linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang" + +[target.armv7-linux-androideabi] +ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" +linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi29-clang" + +[target.i686-linux-android] +ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" +linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android29-clang" + +[target.x86_64-linux-android] +ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" +linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android29-clang" +``` + +**Clang Fix** + In order to get clang to work properly with version 24 you need to create this file. + libgcc.a, then add this one line. + ``` + INPUT(-lunwind) + ``` + +**Folder path: 'Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux'.** +After that you have to copy this file into three different folders namely aarch64, arm, i386 and x86_64. +We have to do this so we Android NDK can find clang on our system, if we used NDK 22 we wouldn't have to do this process. +Though using NDK v22 will not give us a lot of features to work with. +This GitHub [issue](https://github.com/fzyzcjy/flutter_rust_bridge/issues/419) explains the reason why we are doing this. + + --- + + **Android NDK** + + After installing the NDK tools for android you should export the PATH to your config file + (.vimrc, .zshrc, .profile, .bashrc file), That way it can be found. + + ```vim + export PATH=/home/sean/Android/Sdk/ndk/24.0.8215888 + ``` \ No newline at end of file diff --git a/.history/frontend/appflowy_flutter/android/README_20250809205722.md b/.history/frontend/appflowy_flutter/android/README_20250809205722.md new file mode 100644 index 0000000000000..d332589693eea --- /dev/null +++ b/.history/frontend/appflowy_flutter/android/README_20250809205722.md @@ -0,0 +1,96 @@ +# Description + +This is a guide on how to build the rust SDK for AppFlowy on android. +Compiling the sdk is easy it just needs a few tweaks. +When compiling for android we need the following pre-requisites: + +- Android NDK Tools. (v24 has been tested). +- Cargo NDK. (@latest version). + +**Getting the tools** +- Install cargo-ndk ```bash cargo install cargo-ndk```. +- [Download](https://developer.android.com/ndk/downloads/) Android NDK version 24. +- When downloading Android NDK you can get the compressed version as a standalone from the site. + Or you can download it through [Android Studio](https://developer.android.com/studio). +- After downloading the two you need to set the environment variables. The process differs by operating system. +- The variables needed are '$ANDROID_NDK_HOME', this will point to where the NDK is located. + +**Setting Environment Variables** + +**Windows:** +```cmd +set ANDROID_NDK_HOME=C:\Users\%USERNAME%\AppData\Local\Android\Sdk\ndk\24.0.8215888 +``` +Or add to your system environment variables permanently. + +**macOS/Linux:** +```bash +export ANDROID_NDK_HOME=~/Android/Sdk/ndk/24.0.8215888 +``` +--- + +**Cargo Config File** +This code needs to be written in `~/.cargo/config` (Linux/macOS) or `%USERPROFILE%\.cargo\config` (Windows). This helps cargo know where to locate the android tools (linker and archiver). +**NB** Replace the paths with your actual NDK installation location. + +**Linux/macOS:** +```toml +[target.aarch64-linux-android] +ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" +linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang" + +[target.armv7-linux-androideabi] +ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" +linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi29-clang" + +[target.i686-linux-android] +ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" +linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android29-clang" + +[target.x86_64-linux-android] +ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" +linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android29-clang" +``` + +**Windows:** +```toml +[target.aarch64-linux-android] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\aarch64-linux-android29-clang.exe" + +[target.armv7-linux-androideabi] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\armv7a-linux-androideabi29-clang.exe" + +[target.i686-linux-android] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\i686-linux-android29-clang.exe" + +[target.x86_64-linux-android] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\x86_64-linux-android29-clang.exe" +``` + +**Clang Fix** + In order to get clang to work properly with version 24 you need to create this file. + libgcc.a, then add this one line. + ``` + INPUT(-lunwind) + ``` + +**Folder path: 'Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux'.** +After that you have to copy this file into three different folders namely aarch64, arm, i386 and x86_64. +We have to do this so we Android NDK can find clang on our system, if we used NDK 22 we wouldn't have to do this process. +Though using NDK v22 will not give us a lot of features to work with. +This GitHub [issue](https://github.com/fzyzcjy/flutter_rust_bridge/issues/419) explains the reason why we are doing this. + + --- + + **Android NDK** + + After installing the NDK tools for android you should export the PATH to your config file + (.vimrc, .zshrc, .profile, .bashrc file), That way it can be found. + + ```vim + export PATH=/home/sean/Android/Sdk/ndk/24.0.8215888 + ``` \ No newline at end of file diff --git a/.history/frontend/appflowy_flutter/android/README_20250809205734.md b/.history/frontend/appflowy_flutter/android/README_20250809205734.md new file mode 100644 index 0000000000000..d8accecbed209 --- /dev/null +++ b/.history/frontend/appflowy_flutter/android/README_20250809205734.md @@ -0,0 +1,100 @@ +# Description + +This is a guide on how to build the rust SDK for AppFlowy on android. +Compiling the sdk is easy it just needs a few tweaks. +When compiling for android we need the following pre-requisites: + +- Android NDK Tools. (v24 has been tested). +- Cargo NDK. (@latest version). + +**Getting the tools** +- Install cargo-ndk ```bash cargo install cargo-ndk```. +- [Download](https://developer.android.com/ndk/downloads/) Android NDK version 24. +- When downloading Android NDK you can get the compressed version as a standalone from the site. + Or you can download it through [Android Studio](https://developer.android.com/studio). +- After downloading the two you need to set the environment variables. The process differs by operating system. +- The variables needed are '$ANDROID_NDK_HOME', this will point to where the NDK is located. + +**Setting Environment Variables** + +**Windows:** +```cmd +set ANDROID_NDK_HOME=C:\Users\%USERNAME%\AppData\Local\Android\Sdk\ndk\24.0.8215888 +``` +Or add to your system environment variables permanently. + +**macOS/Linux:** +```bash +export ANDROID_NDK_HOME=~/Android/Sdk/ndk/24.0.8215888 +``` +--- + +**Cargo Config File** +This code needs to be written in `~/.cargo/config` (Linux/macOS) or `%USERPROFILE%\.cargo\config` (Windows). This helps cargo know where to locate the android tools (linker and archiver). +**NB** Replace the paths with your actual NDK installation location. + +**Linux/macOS:** +```toml +[target.aarch64-linux-android] +ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" +linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang" + +[target.armv7-linux-androideabi] +ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" +linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi29-clang" + +[target.i686-linux-android] +ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" +linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android29-clang" + +[target.x86_64-linux-android] +ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" +linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android29-clang" +``` + +**Windows:** +```toml +[target.aarch64-linux-android] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\aarch64-linux-android29-clang.exe" + +[target.armv7-linux-androideabi] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\armv7a-linux-androideabi29-clang.exe" + +[target.i686-linux-android] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\i686-linux-android29-clang.exe" + +[target.x86_64-linux-android] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\x86_64-linux-android29-clang.exe" +``` + +**Clang Fix** +In order to get clang to work properly with version 24 you need to create this file. +Create a file named `libgcc.a` with this one line: +``` +INPUT(-lunwind) +``` + +**Linux/macOS:** +Folder path: `Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux/` + +**Windows:** +Folder path: `Android\Sdk\ndk\24.0.8215888\toolchains\llvm\prebuilt\windows-x86_64\lib64\clang\14.0.1\lib\linux\` + +After creating the file, copy it into four different folders: `aarch64`, `arm`, `i386` and `x86_64`. +We have to do this so the Android NDK can find clang on our system. If we used NDK 22 we wouldn't have to do this process, though using NDK v22 will not give us a lot of features to work with. +This GitHub [issue](https://github.com/fzyzcjy/flutter_rust_bridge/issues/419) explains the reason why we are doing this. + + --- + + **Android NDK** + + After installing the NDK tools for android you should export the PATH to your config file + (.vimrc, .zshrc, .profile, .bashrc file), That way it can be found. + + ```vim + export PATH=/home/sean/Android/Sdk/ndk/24.0.8215888 + ``` \ No newline at end of file diff --git a/.history/frontend/appflowy_flutter/android/README_20250809205743.md b/.history/frontend/appflowy_flutter/android/README_20250809205743.md new file mode 100644 index 0000000000000..c76a3b09958a0 --- /dev/null +++ b/.history/frontend/appflowy_flutter/android/README_20250809205743.md @@ -0,0 +1,119 @@ +# Description + +This is a guide on how to build the rust SDK for AppFlowy on android. +Compiling the sdk is easy it just needs a few tweaks. +When compiling for android we need the following pre-requisites: + +- Android NDK Tools. (v24 has been tested). +- Cargo NDK. (@latest version). + +**Getting the tools** +- Install cargo-ndk ```bash cargo install cargo-ndk```. +- [Download](https://developer.android.com/ndk/downloads/) Android NDK version 24. +- When downloading Android NDK you can get the compressed version as a standalone from the site. + Or you can download it through [Android Studio](https://developer.android.com/studio). +- After downloading the two you need to set the environment variables. The process differs by operating system. +- The variables needed are '$ANDROID_NDK_HOME', this will point to where the NDK is located. + +**Setting Environment Variables** + +**Windows:** +```cmd +set ANDROID_NDK_HOME=C:\Users\%USERNAME%\AppData\Local\Android\Sdk\ndk\24.0.8215888 +``` +Or add to your system environment variables permanently. + +**macOS/Linux:** +```bash +export ANDROID_NDK_HOME=~/Android/Sdk/ndk/24.0.8215888 +``` +--- + +**Cargo Config File** +This code needs to be written in `~/.cargo/config` (Linux/macOS) or `%USERPROFILE%\.cargo\config` (Windows). This helps cargo know where to locate the android tools (linker and archiver). +**NB** Replace the paths with your actual NDK installation location. + +**Linux/macOS:** +```toml +[target.aarch64-linux-android] +ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" +linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang" + +[target.armv7-linux-androideabi] +ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" +linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi29-clang" + +[target.i686-linux-android] +ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" +linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android29-clang" + +[target.x86_64-linux-android] +ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" +linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android29-clang" +``` + +**Windows:** +```toml +[target.aarch64-linux-android] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\aarch64-linux-android29-clang.exe" + +[target.armv7-linux-androideabi] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\armv7a-linux-androideabi29-clang.exe" + +[target.i686-linux-android] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\i686-linux-android29-clang.exe" + +[target.x86_64-linux-android] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\x86_64-linux-android29-clang.exe" +``` + +**Clang Fix** +In order to get clang to work properly with version 24 you need to create this file. +Create a file named `libgcc.a` with this one line: +``` +INPUT(-lunwind) +``` + +**Linux/macOS:** +Folder path: `Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux/` + +**Windows:** +Folder path: `Android\Sdk\ndk\24.0.8215888\toolchains\llvm\prebuilt\windows-x86_64\lib64\clang\14.0.1\lib\linux\` + +After creating the file, copy it into four different folders: `aarch64`, `arm`, `i386` and `x86_64`. +We have to do this so the Android NDK can find clang on our system. If we used NDK 22 we wouldn't have to do this process, though using NDK v22 will not give us a lot of features to work with. +This GitHub [issue](https://github.com/fzyzcjy/flutter_rust_bridge/issues/419) explains the reason why we are doing this. + + --- + +**Android NDK Path Setup** + +After installing the NDK tools for Android you should add the NDK path to your system PATH. + +**Linux/macOS:** +Add to your shell config file (.bashrc, .zshrc, .profile): +```bash +export PATH=$PATH:~/Android/Sdk/ndk/24.0.8215888 +``` + +**Windows:** +Add to your system PATH environment variable or add to PowerShell profile: +```powershell +$env:PATH += ";C:\Users\$env:USERNAME\AppData\Local\Android\Sdk\ndk\24.0.8215888" +``` + +**Building AppFlowy Android** + +Once you have completed the setup above, you can build AppFlowy for Android using: + +**All platforms:** +```bash +cd frontend +cargo make appflowy-android +``` + +This will use the appropriate build scripts for your platform (Windows, macOS, or Linux). \ No newline at end of file diff --git a/.history/frontend/scripts/makefile/mobile_20250809205646.toml b/.history/frontend/scripts/makefile/mobile_20250809205646.toml new file mode 100644 index 0000000000000..815e746884cf1 --- /dev/null +++ b/.history/frontend/scripts/makefile/mobile_20250809205646.toml @@ -0,0 +1,171 @@ + +[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", "set-app-version"] +run_task = { name = [ + "setup-crate-type", + "sdk-build-ios", + "post-mobile-ios", + "restore-crate-type", +] } + +[tasks.sdk-build-ios] +dependencies = ["set-app-version"] +private = true +script = [ + """ + cd rust-lib/ + + # Set environment variables for iOS simulator builds to fix bindgen issues + # This prevents the "stdbool.h file not found" error when building for iOS simulator + # Fix the issue: + # error: version 'sim' in target triple 'arm64-apple-ios-sim' is invalid + # rocksdb/include/rocksdb/c.h:65:10: fatal error: 'stdbool.h' file not found + # + + if [[ "${RUST_COMPILE_TARGET}" == *"ios-sim"* ]]; then + echo "🔧 Setting up environment for iOS Simulator build..." + export SDKROOT="$(xcrun --sdk iphonesimulator --show-sdk-path)" + export BINDGEN_EXTRA_CLANG_ARGS="-target arm64-apple-ios14.0-simulator -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path)" + echo "📱 SDKROOT: $SDKROOT" + echo "🛠️ BINDGEN_EXTRA_CLANG_ARGS: $BINDGEN_EXTRA_CLANG_ARGS" + fi + + if [ "${BUILD_FLAG}" = "debug" ]; then + echo "🚀 🚀 🚀 Building iOS SDK for debug" + cargo lipo --targets ${RUST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi + else + echo "🚀 🚀 🚀 Building iOS SDK for release" + cargo lipo --release --targets ${RUST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi + fi + cd ../ + """, +] +script_runner = "@shell" + +[tasks.appflowy-core-dev-android] +category = "Build" +dependencies = ["env_check", "set-app-version"] +run_task = { name = [ + "setup-crate-type", + "sdk-build-android", + "post-mobile-android", + "restore-crate-type", +] } + +# only use in CI job +[tasks.appflowy-core-dev-android-ci] +category = "Build" +dependencies = ["env_check", "set-app-version"] +run_task = { name = [ + "setup-crate-type", + "sdk-build-android-ci", + "post-mobile-android", + "restore-crate-type", +] } + +[tasks.sdk-build-android] +mac_alias = "sdk-build-android-unix" +linux_alias = "sdk-build-android-unix" +windows_alias = "sdk-build-android-windows" + +[tasks.sdk-build-android-unix] +dependencies = ["set-app-version"] +private = true +script = [ + """ + cd rust-lib/ + if [ "${BUILD_FLAG}" = "debug" ]; then + echo "🚀 🚀 🚀 Building Android SDK for debug" + cargo ndk -t arm64-v8a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi + else + echo "🚀 🚀 🚀 Building Android SDK for release" + cargo ndk -t arm64-v8a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi --release + fi + cd ../ + """, +] +script_runner = "@shell" + +[tasks.sdk-build-android-windows] +dependencies = ["set-app-version"] +private = true +script = [ + """ + cd rust-lib + if eq ${BUILD_FLAG} debug + echo "🚀 🚀 🚀 Building Android SDK for debug" + exec cargo ndk -t arm64-v8a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi + else + echo "🚀 🚀 🚀 Building Android SDK for release" + exec cargo ndk -t arm64-v8a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi --release + end + cd .. + """, +] +script_runner = "@duckscript" + +# only use in CI job +[tasks.sdk-build-android-ci] +dependencies = ["set-app-version"] +private = true +script = [ + """ + cd rust-lib/ + cargo ndk -t arm64-v8a -t armeabi-v7a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi + 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" + +[tasks.post-mobile-android] +script = [ + """ + echo "🚀 🚀 🚀 AppFlowy-Core for Android platform build success" + dart_ffi_dir= set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/appflowy_flutter/android/app/src/main + lib = set lib${LIB_NAME}.${LIB_EXT} + + echo "💻 💻 💻 Copying ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/jniLibs/ to ${dart_ffi_dir}/" + rm -r ${dart_ffi_dir}/jniLibs + cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/jniLibs/ \ + ${dart_ffi_dir}/ + + 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" diff --git a/.history/frontend/scripts/makefile/mobile_20250809205653.toml b/.history/frontend/scripts/makefile/mobile_20250809205653.toml new file mode 100644 index 0000000000000..f0ef6162c41c2 --- /dev/null +++ b/.history/frontend/scripts/makefile/mobile_20250809205653.toml @@ -0,0 +1,188 @@ + +[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", "set-app-version"] +run_task = { name = [ + "setup-crate-type", + "sdk-build-ios", + "post-mobile-ios", + "restore-crate-type", +] } + +[tasks.sdk-build-ios] +dependencies = ["set-app-version"] +private = true +script = [ + """ + cd rust-lib/ + + # Set environment variables for iOS simulator builds to fix bindgen issues + # This prevents the "stdbool.h file not found" error when building for iOS simulator + # Fix the issue: + # error: version 'sim' in target triple 'arm64-apple-ios-sim' is invalid + # rocksdb/include/rocksdb/c.h:65:10: fatal error: 'stdbool.h' file not found + # + + if [[ "${RUST_COMPILE_TARGET}" == *"ios-sim"* ]]; then + echo "🔧 Setting up environment for iOS Simulator build..." + export SDKROOT="$(xcrun --sdk iphonesimulator --show-sdk-path)" + export BINDGEN_EXTRA_CLANG_ARGS="-target arm64-apple-ios14.0-simulator -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path)" + echo "📱 SDKROOT: $SDKROOT" + echo "🛠️ BINDGEN_EXTRA_CLANG_ARGS: $BINDGEN_EXTRA_CLANG_ARGS" + fi + + if [ "${BUILD_FLAG}" = "debug" ]; then + echo "🚀 🚀 🚀 Building iOS SDK for debug" + cargo lipo --targets ${RUST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi + else + echo "🚀 🚀 🚀 Building iOS SDK for release" + cargo lipo --release --targets ${RUST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi + fi + cd ../ + """, +] +script_runner = "@shell" + +[tasks.appflowy-core-dev-android] +category = "Build" +dependencies = ["env_check", "set-app-version"] +run_task = { name = [ + "setup-crate-type", + "sdk-build-android", + "post-mobile-android", + "restore-crate-type", +] } + +# only use in CI job +[tasks.appflowy-core-dev-android-ci] +category = "Build" +dependencies = ["env_check", "set-app-version"] +run_task = { name = [ + "setup-crate-type", + "sdk-build-android-ci", + "post-mobile-android", + "restore-crate-type", +] } + +[tasks.sdk-build-android] +mac_alias = "sdk-build-android-unix" +linux_alias = "sdk-build-android-unix" +windows_alias = "sdk-build-android-windows" + +[tasks.sdk-build-android-unix] +dependencies = ["set-app-version"] +private = true +script = [ + """ + cd rust-lib/ + if [ "${BUILD_FLAG}" = "debug" ]; then + echo "🚀 🚀 🚀 Building Android SDK for debug" + cargo ndk -t arm64-v8a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi + else + echo "🚀 🚀 🚀 Building Android SDK for release" + cargo ndk -t arm64-v8a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi --release + fi + cd ../ + """, +] +script_runner = "@shell" + +[tasks.sdk-build-android-windows] +dependencies = ["set-app-version"] +private = true +script = [ + """ + cd rust-lib + if eq ${BUILD_FLAG} debug + echo "🚀 🚀 🚀 Building Android SDK for debug" + exec cargo ndk -t arm64-v8a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi + else + echo "🚀 🚀 🚀 Building Android SDK for release" + exec cargo ndk -t arm64-v8a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi --release + end + cd .. + """, +] +script_runner = "@duckscript" + +# only use in CI job +[tasks.sdk-build-android-ci] +mac_alias = "sdk-build-android-ci-unix" +linux_alias = "sdk-build-android-ci-unix" +windows_alias = "sdk-build-android-ci-windows" + +[tasks.sdk-build-android-ci-unix] +dependencies = ["set-app-version"] +private = true +script = [ + """ + cd rust-lib/ + cargo ndk -t arm64-v8a -t armeabi-v7a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi + cd ../ + """, +] +script_runner = "@shell" + +[tasks.sdk-build-android-ci-windows] +dependencies = ["set-app-version"] +private = true +script = [ + """ + cd rust-lib + exec cargo ndk -t arm64-v8a -t armeabi-v7a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi + cd .. + """, +] +script_runner = "@duckscript" + +[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" + +[tasks.post-mobile-android] +script = [ + """ + echo "🚀 🚀 🚀 AppFlowy-Core for Android platform build success" + dart_ffi_dir= set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/appflowy_flutter/android/app/src/main + lib = set lib${LIB_NAME}.${LIB_EXT} + + echo "💻 💻 💻 Copying ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/jniLibs/ to ${dart_ffi_dir}/" + rm -r ${dart_ffi_dir}/jniLibs + cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/jniLibs/ \ + ${dart_ffi_dir}/ + + 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" diff --git a/README.md b/README.md index 565908e756859..c85d798a76225 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,9 @@ AppFlowy is the AI workspace where you achieve more without losing control of yo ## Getting Started with development -Please view the [documentation](https://docs.appflowy.io/docs/documentation/appflowy/from-source) for OS specific -development instructions +Please view our comprehensive [build from source guide](doc/BUILD_FROM_SOURCE.md) for detailed OS-specific development instructions, including desktop and mobile platform support. + +For additional documentation, visit [docs.appflowy.io](https://docs.appflowy.io/docs/documentation/appflowy/from-source). ## Roadmap diff --git a/doc/BUILD_FROM_SOURCE.md b/doc/BUILD_FROM_SOURCE.md new file mode 100644 index 0000000000000..dcc17beb3d72e --- /dev/null +++ b/doc/BUILD_FROM_SOURCE.md @@ -0,0 +1,219 @@ +# Building AppFlowy from Source + +This guide provides comprehensive instructions for building AppFlowy from source code on all supported platforms. + +## Prerequisites + +Before building AppFlowy, ensure you have the following installed: + +### All Platforms +- [Git](https://git-scm.com/) +- [Rust](https://rustup.rs/) (1.70 or later) +- [Flutter](https://flutter.dev/docs/get-started/install) (3.13.19 or later) +- [cargo-make](https://github.com/sagiegurari/cargo-make) - Install with: `cargo install cargo-make` + +### Platform-Specific Requirements + +#### Windows +- [Visual Studio 2019/2022](https://visualstudio.microsoft.com/) with C++ development tools +- [vcpkg](https://github.com/microsoft/vcpkg) + +#### macOS +- Xcode Command Line Tools: `xcode-select --install` + +#### Linux +- Build essentials: `sudo apt install build-essential pkg-config libssl-dev` +- Additional dependencies: `sudo apt install clang cmake ninja-build pkg-config libgtk-3-dev` + +## Building for Desktop + +### 1. Clone the Repository +```bash +git clone https://github.com/AppFlowy-IO/AppFlowy.git +cd AppFlowy +``` + +### 2. Build for Your Platform + +#### Windows +```bash +cd frontend +cargo make appflowy-windows +``` + +#### macOS +```bash +cd frontend +cargo make appflowy-macos +``` + +#### Linux +```bash +cd frontend +cargo make appflowy-linux +``` + +### 3. Run the Application + +After building, the executable will be located in: +- **Windows**: `frontend/appflowy_flutter/product/[version]/windows/Release/AppFlowy/` +- **macOS**: `frontend/appflowy_flutter/product/[version]/macos/Release/AppFlowy.app/` +- **Linux**: `frontend/appflowy_flutter/product/[version]/linux/Release/AppFlowy/` + +## Building for Mobile + +### iOS + +#### Prerequisites +- macOS with Xcode installed +- iOS development setup for Flutter + +#### Build Steps +```bash +cd frontend +cargo make appflowy-ios +``` + +The iOS app will be built and available in `frontend/appflowy_flutter/build/ios/`. + +### Android + +#### Prerequisites + +**All Platforms:** +- [Android NDK](https://developer.android.com/ndk/downloads/) version 24 +- cargo-ndk: `cargo install cargo-ndk` + +**Additional Setup:** + +1. **Set Environment Variables** + + **Windows:** + ```cmd + set ANDROID_NDK_HOME=C:\Users\%USERNAME%\AppData\Local\Android\Sdk\ndk\24.0.8215888 + ``` + + **macOS/Linux:** + ```bash + export ANDROID_NDK_HOME=~/Android/Sdk/ndk/24.0.8215888 + ``` + +2. **Configure Cargo for Android** + + Create or edit `~/.cargo/config` (Linux/macOS) or `%USERPROFILE%\.cargo\config` (Windows): + + **Linux/macOS:** + ```toml + [target.aarch64-linux-android] + ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" + linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang" + + [target.armv7-linux-androideabi] + ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" + linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi29-clang" + + [target.i686-linux-android] + ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" + linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android29-clang" + + [target.x86_64-linux-android] + ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" + linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android29-clang" + ``` + + **Windows:** + ```toml + [target.aarch64-linux-android] + ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" + linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\aarch64-linux-android29-clang.exe" + + [target.armv7-linux-androideabi] + ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" + linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\armv7a-linux-androideabi29-clang.exe" + + [target.i686-linux-android] + ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" + linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\i686-linux-android29-clang.exe" + + [target.x86_64-linux-android] + ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" + linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\x86_64-linux-android29-clang.exe" + ``` + +3. **NDK 24 Clang Fix** + + Create a file named `libgcc.a` with this content: + ``` + INPUT(-lunwind) + ``` + + **Linux/macOS:** Place it in `Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux/` + + **Windows:** Place it in `Android\Sdk\ndk\24.0.8215888\toolchains\llvm\prebuilt\windows-x86_64\lib64\clang\14.0.1\lib\linux\` + + Copy this file to the following subdirectories: `aarch64`, `arm`, `i386`, and `x86_64`. + +#### Build Steps +```bash +cd frontend +cargo make appflowy-android +``` + +The Android APK will be built and available in `frontend/appflowy_flutter/build/app/outputs/flutter-apk/`. + +## Development Builds + +For faster development builds without optimizations: + +### Desktop Development +```bash +cd frontend +cargo make appflowy-dev # Uses platform-specific aliases +``` + +### Mobile Development +```bash +# iOS development build +cd frontend +cargo make appflowy-ios-dev + +# Android development build +cd frontend +cargo make appflowy-android-dev +``` + +## Troubleshooting + +### Common Issues + +1. **Flutter Doctor Issues**: Run `flutter doctor` to check for missing dependencies +2. **Rust Version**: Ensure you're using Rust 1.70 or later +3. **Path Issues**: Make sure all tools are in your system PATH +4. **NDK Issues**: Verify ANDROID_NDK_HOME is set correctly + +### Platform-Specific Issues + +#### Windows +- Ensure Visual Studio C++ tools are installed +- Check that vcpkg is properly configured +- Use PowerShell or Command Prompt, not Git Bash for building + +#### macOS +- Ensure Xcode Command Line Tools are installed +- For iOS builds, you need a full Xcode installation + +#### Linux +- Install all required system dependencies +- Check that pkg-config can find required libraries + +### Getting Help + +- Check the [AppFlowy Documentation](https://docs.appflowy.io/) +- Join our [Discord](https://discord.gg/9Q2xaN37tV) for community support +- Report issues on [GitHub](https://github.com/AppFlowy-IO/AppFlowy/issues) + +## Additional Resources + +- [AppFlowy Development Guide](https://docs.appflowy.io/docs/documentation/appflowy/from-source) +- [Contributing Guidelines](CONTRIBUTING.md) +- [Android-specific instructions](../frontend/appflowy_flutter/android/README.md) diff --git a/frontend/appflowy_flutter/.metadata b/frontend/appflowy_flutter/.metadata index 7da2cb55fdd75..128495f59d55a 100644 --- a/frontend/appflowy_flutter/.metadata +++ b/frontend/appflowy_flutter/.metadata @@ -1,11 +1,11 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled. +# This file should be version controlled and should not be manually edited. version: - revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66 - channel: unknown + revision: "d8a9f9a52e5af486f80d932e838ee93861ffd863" + channel: "[user-branch]" project_type: app @@ -13,11 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66 - base_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66 + create_revision: d8a9f9a52e5af486f80d932e838ee93861ffd863 + base_revision: d8a9f9a52e5af486f80d932e838ee93861ffd863 - platform: android - create_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66 - base_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66 + create_revision: d8a9f9a52e5af486f80d932e838ee93861ffd863 + base_revision: d8a9f9a52e5af486f80d932e838ee93861ffd863 # User provided section diff --git a/frontend/appflowy_flutter/README.md b/frontend/appflowy_flutter/README.md index 116cd63f22b54..b8f224356417d 100644 --- a/frontend/appflowy_flutter/README.md +++ b/frontend/appflowy_flutter/README.md @@ -32,7 +32,11 @@ To contribute to `AppFlowy_Flutter` codebase specifically (coding contribution) ### What OS should I use for development? -We support all OS for Development i.e. Linux, MacOS and Windows. However, most of us promote macOS and Linux over Windows. We have detailed [docs](https://docs.appflowy.io/docs/documentation/appflowy/from-source/environment-setup) on how to setup `AppFlowy_Flutter` on your local system respectively per operating system. +We support all OS for Development i.e. Linux, MacOS and Windows. We have detailed documentation on how to setup `AppFlowy_Flutter` on your local system for each operating system: + +- [Build from Source Guide](../../doc/BUILD_FROM_SOURCE.md) - Comprehensive setup instructions for all platforms +- [Android-specific Guide](android/README.md) - Detailed Android build instructions including Windows support +- [Online Documentation](https://docs.appflowy.io/docs/documentation/appflowy/from-source/environment-setup) - Additional setup resources ### Getting Started ❇ diff --git a/frontend/appflowy_flutter/android/README.md b/frontend/appflowy_flutter/android/README.md index 52f0dd3e6fd03..c76a3b09958a0 100644 --- a/frontend/appflowy_flutter/android/README.md +++ b/frontend/appflowy_flutter/android/README.md @@ -12,15 +12,28 @@ When compiling for android we need the following pre-requisites: - [Download](https://developer.android.com/ndk/downloads/) Android NDK version 24. - When downloading Android NDK you can get the compressed version as a standalone from the site. Or you can download it through [Android Studio](https://developer.android.com/studio). -- After downloading the two you need to set the environment variables. For Windows that's a separate process. - On macOS and Linux the process is similar. +- After downloading the two you need to set the environment variables. The process differs by operating system. - The variables needed are '$ANDROID_NDK_HOME', this will point to where the NDK is located. + +**Setting Environment Variables** + +**Windows:** +```cmd +set ANDROID_NDK_HOME=C:\Users\%USERNAME%\AppData\Local\Android\Sdk\ndk\24.0.8215888 +``` +Or add to your system environment variables permanently. + +**macOS/Linux:** +```bash +export ANDROID_NDK_HOME=~/Android/Sdk/ndk/24.0.8215888 +``` --- **Cargo Config File** -This code needs to be written in ~/.cargo/config, this helps cargo know where to locate the android tools(linker and archiver). -**NB** Keep in mind just replace 'user' with your own user name. Or just point it to the location of where you put the NDK. +This code needs to be written in `~/.cargo/config` (Linux/macOS) or `%USERPROFILE%\.cargo\config` (Windows). This helps cargo know where to locate the android tools (linker and archiver). +**NB** Replace the paths with your actual NDK installation location. +**Linux/macOS:** ```toml [target.aarch64-linux-android] ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" @@ -39,26 +52,68 @@ ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86 linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android29-clang" ``` +**Windows:** +```toml +[target.aarch64-linux-android] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\aarch64-linux-android29-clang.exe" + +[target.armv7-linux-androideabi] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\armv7a-linux-androideabi29-clang.exe" + +[target.i686-linux-android] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\i686-linux-android29-clang.exe" + +[target.x86_64-linux-android] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\x86_64-linux-android29-clang.exe" +``` + **Clang Fix** - In order to get clang to work properly with version 24 you need to create this file. - libgcc.a, then add this one line. - ``` - INPUT(-lunwind) - ``` - -**Folder path: 'Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux'.** -After that you have to copy this file into three different folders namely aarch64, arm, i386 and x86_64. -We have to do this so we Android NDK can find clang on our system, if we used NDK 22 we wouldn't have to do this process. -Though using NDK v22 will not give us a lot of features to work with. +In order to get clang to work properly with version 24 you need to create this file. +Create a file named `libgcc.a` with this one line: +``` +INPUT(-lunwind) +``` + +**Linux/macOS:** +Folder path: `Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux/` + +**Windows:** +Folder path: `Android\Sdk\ndk\24.0.8215888\toolchains\llvm\prebuilt\windows-x86_64\lib64\clang\14.0.1\lib\linux\` + +After creating the file, copy it into four different folders: `aarch64`, `arm`, `i386` and `x86_64`. +We have to do this so the Android NDK can find clang on our system. If we used NDK 22 we wouldn't have to do this process, though using NDK v22 will not give us a lot of features to work with. This GitHub [issue](https://github.com/fzyzcjy/flutter_rust_bridge/issues/419) explains the reason why we are doing this. --- - **Android NDK** +**Android NDK Path Setup** + +After installing the NDK tools for Android you should add the NDK path to your system PATH. - After installing the NDK tools for android you should export the PATH to your config file - (.vimrc, .zshrc, .profile, .bashrc file), That way it can be found. +**Linux/macOS:** +Add to your shell config file (.bashrc, .zshrc, .profile): +```bash +export PATH=$PATH:~/Android/Sdk/ndk/24.0.8215888 +``` + +**Windows:** +Add to your system PATH environment variable or add to PowerShell profile: +```powershell +$env:PATH += ";C:\Users\$env:USERNAME\AppData\Local\Android\Sdk\ndk\24.0.8215888" +``` + +**Building AppFlowy Android** + +Once you have completed the setup above, you can build AppFlowy for Android using: + +**All platforms:** +```bash +cd frontend +cargo make appflowy-android +``` - ```vim - export PATH=/home/sean/Android/Sdk/ndk/24.0.8215888 - ``` \ No newline at end of file +This will use the appropriate build scripts for your platform (Windows, macOS, or Linux). \ No newline at end of file diff --git a/frontend/appflowy_flutter/android/app/src/main/kotlin/io/appflowy/appflowy/MainActivity.kt b/frontend/appflowy_flutter/android/app/src/main/kotlin/io/appflowy/appflowy/MainActivity.kt new file mode 100644 index 0000000000000..c380c8bf1f458 --- /dev/null +++ b/frontend/appflowy_flutter/android/app/src/main/kotlin/io/appflowy/appflowy/MainActivity.kt @@ -0,0 +1,5 @@ +package io.appflowy.appflowy + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() diff --git a/frontend/appflowy_flutter/android/app/src/main/res/drawable/launch_background.xml b/frontend/appflowy_flutter/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000000000..304732f884201 --- /dev/null +++ b/frontend/appflowy_flutter/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/frontend/scripts/makefile/mobile.toml b/frontend/scripts/makefile/mobile.toml index 6f89c1235ebd6..f0ef6162c41c2 100644 --- a/frontend/scripts/makefile/mobile.toml +++ b/frontend/scripts/makefile/mobile.toml @@ -76,6 +76,11 @@ run_task = { name = [ ] } [tasks.sdk-build-android] +mac_alias = "sdk-build-android-unix" +linux_alias = "sdk-build-android-unix" +windows_alias = "sdk-build-android-windows" + +[tasks.sdk-build-android-unix] dependencies = ["set-app-version"] private = true script = [ @@ -93,8 +98,31 @@ script = [ ] script_runner = "@shell" +[tasks.sdk-build-android-windows] +dependencies = ["set-app-version"] +private = true +script = [ + """ + cd rust-lib + if eq ${BUILD_FLAG} debug + echo "🚀 🚀 🚀 Building Android SDK for debug" + exec cargo ndk -t arm64-v8a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi + else + echo "🚀 🚀 🚀 Building Android SDK for release" + exec cargo ndk -t arm64-v8a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi --release + end + cd .. + """, +] +script_runner = "@duckscript" + # only use in CI job [tasks.sdk-build-android-ci] +mac_alias = "sdk-build-android-ci-unix" +linux_alias = "sdk-build-android-ci-unix" +windows_alias = "sdk-build-android-ci-windows" + +[tasks.sdk-build-android-ci-unix] dependencies = ["set-app-version"] private = true script = [ @@ -106,6 +134,18 @@ script = [ ] script_runner = "@shell" +[tasks.sdk-build-android-ci-windows] +dependencies = ["set-app-version"] +private = true +script = [ + """ + cd rust-lib + exec cargo ndk -t arm64-v8a -t armeabi-v7a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi + cd .. + """, +] +script_runner = "@duckscript" + [tasks.post-mobile-ios] private = true script = [ From c3c839098a6cba8c8ccd7d7e422c721d21f0674e Mon Sep 17 00:00:00 2001 From: Akhash S Date: Sat, 9 Aug 2025 23:48:21 -0700 Subject: [PATCH 2/3] fix: Address code review feedback - Remove .history folders from commit - Fix 'macOS' spelling (was 'MacOS') - Add armeabi-v7a target to Windows Android build scripts for ABI parity - Remove duplicated Android setup instructions, reference dedicated guide instead - Remove unrelated Android app files from commit scope Addresses feedback from PR #8163 --- README.md | 5 +- doc/BUILD_FROM_SOURCE.md | 160 ++++++++++++++++++++ frontend/appflowy_flutter/.metadata | 14 +- frontend/appflowy_flutter/README.md | 6 +- frontend/appflowy_flutter/android/README.md | 95 +++++++++--- frontend/scripts/makefile/mobile.toml | 40 +++++ 6 files changed, 290 insertions(+), 30 deletions(-) create mode 100644 doc/BUILD_FROM_SOURCE.md diff --git a/README.md b/README.md index 565908e756859..c85d798a76225 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,9 @@ AppFlowy is the AI workspace where you achieve more without losing control of yo ## Getting Started with development -Please view the [documentation](https://docs.appflowy.io/docs/documentation/appflowy/from-source) for OS specific -development instructions +Please view our comprehensive [build from source guide](doc/BUILD_FROM_SOURCE.md) for detailed OS-specific development instructions, including desktop and mobile platform support. + +For additional documentation, visit [docs.appflowy.io](https://docs.appflowy.io/docs/documentation/appflowy/from-source). ## Roadmap diff --git a/doc/BUILD_FROM_SOURCE.md b/doc/BUILD_FROM_SOURCE.md new file mode 100644 index 0000000000000..d17bca9273d48 --- /dev/null +++ b/doc/BUILD_FROM_SOURCE.md @@ -0,0 +1,160 @@ +# Building AppFlowy from Source + +This guide provides comprehensive instructions for building AppFlowy from source code on all supported platforms. + +## Prerequisites + +Before building AppFlowy, ensure you have the following installed: + +### All Platforms +- [Git](https://git-scm.com/) +- [Rust](https://rustup.rs/) (1.70 or later) +- [Flutter](https://flutter.dev/docs/get-started/install) (3.13.19 or later) +- [cargo-make](https://github.com/sagiegurari/cargo-make) - Install with: `cargo install cargo-make` + +### Platform-Specific Requirements + +#### Windows +- [Visual Studio 2019/2022](https://visualstudio.microsoft.com/) with C++ development tools +- [vcpkg](https://github.com/microsoft/vcpkg) + +#### macOS +- Xcode Command Line Tools: `xcode-select --install` + +#### Linux +- Build essentials: `sudo apt install build-essential pkg-config libssl-dev` +- Additional dependencies: `sudo apt install clang cmake ninja-build pkg-config libgtk-3-dev` + +## Building for Desktop + +### 1. Clone the Repository +```bash +git clone https://github.com/AppFlowy-IO/AppFlowy.git +cd AppFlowy +``` + +### 2. Build for Your Platform + +#### Windows +```bash +cd frontend +cargo make appflowy-windows +``` + +#### macOS +```bash +cd frontend +cargo make appflowy-macos +``` + +#### Linux +```bash +cd frontend +cargo make appflowy-linux +``` + +### 3. Run the Application + +After building, the executable will be located in: +- **Windows**: `frontend/appflowy_flutter/product/[version]/windows/Release/AppFlowy/` +- **macOS**: `frontend/appflowy_flutter/product/[version]/macos/Release/AppFlowy.app/` +- **Linux**: `frontend/appflowy_flutter/product/[version]/linux/Release/AppFlowy/` + +## Building for Mobile + +### iOS + +#### Prerequisites +- macOS with Xcode installed +- iOS development setup for Flutter + +#### Build Steps +```bash +cd frontend +cargo make appflowy-ios +``` + +The iOS app will be built and available in `frontend/appflowy_flutter/build/ios/`. + +### Android + +#### Prerequisites + +**All Platforms:** +- [Android NDK](https://developer.android.com/ndk/downloads/) version 24 +- cargo-ndk: `cargo install cargo-ndk` + +#### Detailed Setup Instructions + +For comprehensive Android build setup including Windows support, please refer to the [Android-specific build guide](../frontend/appflowy_flutter/android/README.md) which covers: + +- Platform-specific environment variable setup +- Cargo configuration for all operating systems +- NDK 24 clang fixes +- Path configuration +- Troubleshooting common issues + +#### Build Steps +```bash +cd frontend +cargo make appflowy-android +``` + +The Android APK will be built and available in `frontend/appflowy_flutter/build/app/outputs/flutter-apk/`. + +## Development Builds + +For faster development builds without optimizations: + +### Desktop Development +```bash +cd frontend +cargo make appflowy-dev # Uses platform-specific aliases +``` + +### Mobile Development +```bash +# iOS development build +cd frontend +cargo make appflowy-ios-dev + +# Android development build +cd frontend +cargo make appflowy-android-dev +``` + +## Troubleshooting + +### Common Issues + +1. **Flutter Doctor Issues**: Run `flutter doctor` to check for missing dependencies +2. **Rust Version**: Ensure you're using Rust 1.70 or later +3. **Path Issues**: Make sure all tools are in your system PATH +4. **NDK Issues**: Verify ANDROID_NDK_HOME is set correctly + +### Platform-Specific Issues + +#### Windows +- Ensure Visual Studio C++ tools are installed +- Check that vcpkg is properly configured +- Use PowerShell or Command Prompt, not Git Bash for building + +#### macOS +- Ensure Xcode Command Line Tools are installed +- For iOS builds, you need a full Xcode installation + +#### Linux +- Install all required system dependencies +- Check that pkg-config can find required libraries + +### Getting Help + +- Check the [AppFlowy Documentation](https://docs.appflowy.io/) +- Join our [Discord](https://discord.gg/9Q2xaN37tV) for community support +- Report issues on [GitHub](https://github.com/AppFlowy-IO/AppFlowy/issues) + +## Additional Resources + +- [AppFlowy Development Guide](https://docs.appflowy.io/docs/documentation/appflowy/from-source) +- [Contributing Guidelines](CONTRIBUTING.md) +- [Android-specific instructions](../frontend/appflowy_flutter/android/README.md) diff --git a/frontend/appflowy_flutter/.metadata b/frontend/appflowy_flutter/.metadata index 7da2cb55fdd75..128495f59d55a 100644 --- a/frontend/appflowy_flutter/.metadata +++ b/frontend/appflowy_flutter/.metadata @@ -1,11 +1,11 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled. +# This file should be version controlled and should not be manually edited. version: - revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66 - channel: unknown + revision: "d8a9f9a52e5af486f80d932e838ee93861ffd863" + channel: "[user-branch]" project_type: app @@ -13,11 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66 - base_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66 + create_revision: d8a9f9a52e5af486f80d932e838ee93861ffd863 + base_revision: d8a9f9a52e5af486f80d932e838ee93861ffd863 - platform: android - create_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66 - base_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66 + create_revision: d8a9f9a52e5af486f80d932e838ee93861ffd863 + base_revision: d8a9f9a52e5af486f80d932e838ee93861ffd863 # User provided section diff --git a/frontend/appflowy_flutter/README.md b/frontend/appflowy_flutter/README.md index 116cd63f22b54..a172764a04833 100644 --- a/frontend/appflowy_flutter/README.md +++ b/frontend/appflowy_flutter/README.md @@ -32,7 +32,11 @@ To contribute to `AppFlowy_Flutter` codebase specifically (coding contribution) ### What OS should I use for development? -We support all OS for Development i.e. Linux, MacOS and Windows. However, most of us promote macOS and Linux over Windows. We have detailed [docs](https://docs.appflowy.io/docs/documentation/appflowy/from-source/environment-setup) on how to setup `AppFlowy_Flutter` on your local system respectively per operating system. +We support all OS for Development i.e. Linux, macOS and Windows. We have detailed documentation on how to setup `AppFlowy_Flutter` on your local system for each operating system: + +- [Build from Source Guide](../../doc/BUILD_FROM_SOURCE.md) - Comprehensive setup instructions for all platforms +- [Android-specific Guide](android/README.md) - Detailed Android build instructions including Windows support +- [Online Documentation](https://docs.appflowy.io/docs/documentation/appflowy/from-source/environment-setup) - Additional setup resources ### Getting Started ❇ diff --git a/frontend/appflowy_flutter/android/README.md b/frontend/appflowy_flutter/android/README.md index 52f0dd3e6fd03..c76a3b09958a0 100644 --- a/frontend/appflowy_flutter/android/README.md +++ b/frontend/appflowy_flutter/android/README.md @@ -12,15 +12,28 @@ When compiling for android we need the following pre-requisites: - [Download](https://developer.android.com/ndk/downloads/) Android NDK version 24. - When downloading Android NDK you can get the compressed version as a standalone from the site. Or you can download it through [Android Studio](https://developer.android.com/studio). -- After downloading the two you need to set the environment variables. For Windows that's a separate process. - On macOS and Linux the process is similar. +- After downloading the two you need to set the environment variables. The process differs by operating system. - The variables needed are '$ANDROID_NDK_HOME', this will point to where the NDK is located. + +**Setting Environment Variables** + +**Windows:** +```cmd +set ANDROID_NDK_HOME=C:\Users\%USERNAME%\AppData\Local\Android\Sdk\ndk\24.0.8215888 +``` +Or add to your system environment variables permanently. + +**macOS/Linux:** +```bash +export ANDROID_NDK_HOME=~/Android/Sdk/ndk/24.0.8215888 +``` --- **Cargo Config File** -This code needs to be written in ~/.cargo/config, this helps cargo know where to locate the android tools(linker and archiver). -**NB** Keep in mind just replace 'user' with your own user name. Or just point it to the location of where you put the NDK. +This code needs to be written in `~/.cargo/config` (Linux/macOS) or `%USERPROFILE%\.cargo\config` (Windows). This helps cargo know where to locate the android tools (linker and archiver). +**NB** Replace the paths with your actual NDK installation location. +**Linux/macOS:** ```toml [target.aarch64-linux-android] ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" @@ -39,26 +52,68 @@ ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86 linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android29-clang" ``` +**Windows:** +```toml +[target.aarch64-linux-android] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\aarch64-linux-android29-clang.exe" + +[target.armv7-linux-androideabi] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\armv7a-linux-androideabi29-clang.exe" + +[target.i686-linux-android] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\i686-linux-android29-clang.exe" + +[target.x86_64-linux-android] +ar = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\llvm-ar.exe" +linker = "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk\\ndk\\24.0.8215888\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\x86_64-linux-android29-clang.exe" +``` + **Clang Fix** - In order to get clang to work properly with version 24 you need to create this file. - libgcc.a, then add this one line. - ``` - INPUT(-lunwind) - ``` - -**Folder path: 'Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux'.** -After that you have to copy this file into three different folders namely aarch64, arm, i386 and x86_64. -We have to do this so we Android NDK can find clang on our system, if we used NDK 22 we wouldn't have to do this process. -Though using NDK v22 will not give us a lot of features to work with. +In order to get clang to work properly with version 24 you need to create this file. +Create a file named `libgcc.a` with this one line: +``` +INPUT(-lunwind) +``` + +**Linux/macOS:** +Folder path: `Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux/` + +**Windows:** +Folder path: `Android\Sdk\ndk\24.0.8215888\toolchains\llvm\prebuilt\windows-x86_64\lib64\clang\14.0.1\lib\linux\` + +After creating the file, copy it into four different folders: `aarch64`, `arm`, `i386` and `x86_64`. +We have to do this so the Android NDK can find clang on our system. If we used NDK 22 we wouldn't have to do this process, though using NDK v22 will not give us a lot of features to work with. This GitHub [issue](https://github.com/fzyzcjy/flutter_rust_bridge/issues/419) explains the reason why we are doing this. --- - **Android NDK** +**Android NDK Path Setup** + +After installing the NDK tools for Android you should add the NDK path to your system PATH. - After installing the NDK tools for android you should export the PATH to your config file - (.vimrc, .zshrc, .profile, .bashrc file), That way it can be found. +**Linux/macOS:** +Add to your shell config file (.bashrc, .zshrc, .profile): +```bash +export PATH=$PATH:~/Android/Sdk/ndk/24.0.8215888 +``` + +**Windows:** +Add to your system PATH environment variable or add to PowerShell profile: +```powershell +$env:PATH += ";C:\Users\$env:USERNAME\AppData\Local\Android\Sdk\ndk\24.0.8215888" +``` + +**Building AppFlowy Android** + +Once you have completed the setup above, you can build AppFlowy for Android using: + +**All platforms:** +```bash +cd frontend +cargo make appflowy-android +``` - ```vim - export PATH=/home/sean/Android/Sdk/ndk/24.0.8215888 - ``` \ No newline at end of file +This will use the appropriate build scripts for your platform (Windows, macOS, or Linux). \ No newline at end of file diff --git a/frontend/scripts/makefile/mobile.toml b/frontend/scripts/makefile/mobile.toml index 6f89c1235ebd6..a8d24758abae9 100644 --- a/frontend/scripts/makefile/mobile.toml +++ b/frontend/scripts/makefile/mobile.toml @@ -76,6 +76,11 @@ run_task = { name = [ ] } [tasks.sdk-build-android] +mac_alias = "sdk-build-android-unix" +linux_alias = "sdk-build-android-unix" +windows_alias = "sdk-build-android-windows" + +[tasks.sdk-build-android-unix] dependencies = ["set-app-version"] private = true script = [ @@ -93,8 +98,31 @@ script = [ ] script_runner = "@shell" +[tasks.sdk-build-android-windows] +dependencies = ["set-app-version"] +private = true +script = [ + """ + cd rust-lib + if eq ${BUILD_FLAG} debug + echo "🚀 🚀 🚀 Building Android SDK for debug" + exec cargo ndk -t arm64-v8a -t armeabi-v7a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi + else + echo "🚀 🚀 🚀 Building Android SDK for release" + exec cargo ndk -t arm64-v8a -t armeabi-v7a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi --release + end + cd .. + """, +] +script_runner = "@duckscript" + # only use in CI job [tasks.sdk-build-android-ci] +mac_alias = "sdk-build-android-ci-unix" +linux_alias = "sdk-build-android-ci-unix" +windows_alias = "sdk-build-android-ci-windows" + +[tasks.sdk-build-android-ci-unix] dependencies = ["set-app-version"] private = true script = [ @@ -106,6 +134,18 @@ script = [ ] script_runner = "@shell" +[tasks.sdk-build-android-ci-windows] +dependencies = ["set-app-version"] +private = true +script = [ + """ + cd rust-lib + exec cargo ndk -t arm64-v8a -t armeabi-v7a -o ./jniLibs build --features "${FLUTTER_DESKTOP_FEATURES}" --package=dart-ffi + cd .. + """, +] +script_runner = "@duckscript" + [tasks.post-mobile-ios] private = true script = [ From 03c5c5e0d155cb7feafdefa21c851fab071d89cd Mon Sep 17 00:00:00 2001 From: Akhash Senthilkumar Date: Sun, 10 Aug 2025 21:24:57 +0530 Subject: [PATCH 3/3] Update frontend/appflowy_flutter/README.md Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- frontend/appflowy_flutter/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/appflowy_flutter/README.md b/frontend/appflowy_flutter/README.md index b8f224356417d..a172764a04833 100644 --- a/frontend/appflowy_flutter/README.md +++ b/frontend/appflowy_flutter/README.md @@ -32,7 +32,7 @@ To contribute to `AppFlowy_Flutter` codebase specifically (coding contribution) ### What OS should I use for development? -We support all OS for Development i.e. Linux, MacOS and Windows. We have detailed documentation on how to setup `AppFlowy_Flutter` on your local system for each operating system: +We support all OS for Development i.e. Linux, macOS and Windows. We have detailed documentation on how to setup `AppFlowy_Flutter` on your local system for each operating system: - [Build from Source Guide](../../doc/BUILD_FROM_SOURCE.md) - Comprehensive setup instructions for all platforms - [Android-specific Guide](android/README.md) - Detailed Android build instructions including Windows support