### Installation: Build Bundle Directory Setup Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_package_native_assets/example/linux/CMakeLists.txt Configures the installation prefix to be a relocatable bundle directory within the build directory and ensures it starts clean. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Installation Bundle Configuration Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/gallery/linux/CMakeLists.txt Configures the installation process to create a relocatable application bundle, setting the installation prefix and cleaning the bundle directory before installation. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() # Start with a clean build bundle directory every time. install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") ``` -------------------------------- ### Start Android Emulator Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/manual_tests/frb-local-android-host-runtime-dev-env.md Prepare the Android SDK and AVD, then start the emulator with a stable console port. ```bash .claude/skills/frb-dev-env/frb_dev_env.py android env .claude/skills/frb-dev-env/frb_dev_env.py android emulator --avd FRB_API_35 --port 5554 ``` -------------------------------- ### Installation Configuration for Windows Executable Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_via_integrate/windows/CMakeLists.txt Configures the installation process for the application on Windows. It sets the installation prefix to be adjacent to the executable and ensures the 'install' step is part of the default build. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Configure Installation Paths and Rules Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_via_create/windows/CMakeLists.txt Sets up installation directories and rules for the application binary, assets, and native libraries. ```cmake # === Installation === # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Clone the example repository Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/miscellaneous/92-archived/02-tutorial-with-flutter/01-tutorial.md Use this command to download the example codebase for the Flutter and Rust integration. ```shell git clone https://github.com/fzyzcjy/flutter_rust_bridge && cd flutter_rust_bridge/frb_example/with_flutter ``` -------------------------------- ### Verify Host Environment Setup Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/vmware_windows/README.md Run the check-host script to verify that VMware, Vagrant, and Packer are correctly installed and configured on your host system. This is a crucial step before proceeding with VM preparation. ```bash tools/vmware_windows/frb_vmware_windows_env.py check-host ``` -------------------------------- ### Install Application Executable Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_package_native_assets/example/windows/CMakeLists.txt Installs the main application executable to the runtime destination. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Install Application Executable and Resources Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_via_create_native_assets/linux/CMakeLists.txt Installs the main application executable, ICU data file, Flutter library, and bundled plugin libraries into the installation bundle. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Installation Configuration for Application Bundle Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_via_create/linux/CMakeLists.txt Configures the installation process to create a relocatable application bundle. It cleans the build directory, installs the executable, data files, libraries, and assets. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() # Start with a clean build bundle directory every time. install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) # Install the AOT library on non-Debug builds only. if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Verify Flutter and OpenHarmony Toolchain Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/guides/miscellaneous/harmony-os.md Run this command after setting up the OpenHarmony Flutter toolchain to ensure both Flutter and OpenHarmony components are available. If any component is missing, refer to the environment guide for setup. ```shell flutter doctor -v ``` -------------------------------- ### Install Application Target Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/rust_ui_counter/ui/windows/CMakeLists.txt Installs the main application executable to the specified runtime destination. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Example NDK folder path on Windows Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/miscellaneous/92-archived/02-tutorial-with-flutter/03-alternative-ndk.md An example path on Windows where `libunwind.a` can be found, and where the `libgcc.a` workaround file should be placed. ```text C:\Users\Administrator\AppData\Local\Android\Sdk\ndk\24.0.8215888\toolchains\llvm\prebuilt\windows-x86_64\lib64\clang\14.0.1\lib\linux\x86_64\ ``` -------------------------------- ### Install VMware Vagrant Provider Utility and Plugin Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/vmware_windows/README.md After installing VMware Fusion and Vagrant, install the VMware Vagrant provider utility and the vagrant-vmware-desktop plugin. This ensures Vagrant can interact with VMware. ```bash HOMEBREW_NO_AUTO_UPDATE=1 brew install --cask vagrant-vmware-utility vagrant plugin install vagrant-vmware-desktop ``` -------------------------------- ### Run Pure Dart Example Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/guides/miscellaneous/pure-dart.md Execute the minimal Dart example with the native-assets experiment enabled. ```shell dart --enable-experiment=native-assets run lib/main.dart ``` -------------------------------- ### Installation: Bundle Data and Library Directories Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_package_native_assets/example/linux/CMakeLists.txt Defines the destination paths for data and library files within the installed bundle. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") ``` -------------------------------- ### Install Application Bundle Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_via_integrate/linux/CMakeLists.txt Configures the installation of the application bundle. It ensures a clean build directory, installs the main executable, Flutter ICU data, the Flutter library, bundled plugin libraries, and native assets. It also handles the installation of the AOT library for non-Debug builds. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install build-time dependencies Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/integrate/06-existing/02-deps.md Commands to install required build-time tools for Dart and Flutter projects. ```bash cargo install flutter_rust_bridge_codegen dart pub add --dev ffigen && dart pub add ffi # if building for iOS or MacOS cargo install cargo-xcode ``` ```bash cargo install flutter_rust_bridge_codegen flutter pub add --dev ffigen && flutter pub add ffi # if building for iOS or MacOS cargo install cargo-xcode ``` -------------------------------- ### Start Windows VM Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/manual_tests/frb-local-vmware-windows-dev-env.md Initiates the VMware Windows virtual machine for development. ```bash tools/vmware_windows/frb_vmware_windows_env.py start ``` -------------------------------- ### Example NDK folder path on macOS Monterey Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/miscellaneous/92-archived/02-tutorial-with-flutter/03-alternative-ndk.md An example path on macOS Monterey where `libunwind.a` can be found, and where the `libgcc.a` workaround file should be placed. ```text ~/Library/Android/sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/14.0.1/lib/linux/x86_64/ ``` -------------------------------- ### Install the code generator Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/miscellaneous/92-archived/01-quickstart.md Install the flutter_rust_bridge_codegen tool using cargo, cargo-binstall, scoop, or Homebrew. ```bash cargo install flutter_rust_bridge_codegen # or with cargo-binstall cargo binstall flutter_rust_bridge_codegen # or with scoop (Windows) scoop bucket add frb https://github.com/Desdaemon/scoop-repo scoop install flutter_rust_bridge_codegen # or with Homebrew brew install desdaemon/repo/flutter_rust_bridge_codegen ``` -------------------------------- ### Install Application Target and Runtime Files Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_via_integrate/windows/CMakeLists.txt Installs the main application executable, ICU data file, Flutter library, and any bundled plugin libraries to the specified runtime destinations. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/rust_ui_counter/ui/windows/CMakeLists.txt Installs any bundled libraries provided by plugins to the library directory. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_package_native_assets/example/linux/CMakeLists.txt Iterates through a list of bundled plugin libraries and installs each to the library directory within the bundle. ```cmake foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Install libclang-dev on Linux (apt-get) Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/ffigen-troubleshooting.md Install the libclang-dev package using apt-get for Debian-based Linux distributions. ```bash sudo apt-get install libclang-dev ``` -------------------------------- ### Install clang-devel on Linux (dnf) Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/ffigen-troubleshooting.md Install the clang-devel package using dnf for Fedora-based Linux distributions. ```bash sudo dnf install clang-devel ``` -------------------------------- ### Start Local OCI Registry with Docker Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/tart_macos/README.md This command starts a local OCI registry using Docker. Ensure a large disk is mounted for registry storage to accommodate image data. ```bash mkdir -p /Volumes/MyExternal/temp/frb-mobile-registry docker run -d --name frb-mobile-registry \ -p 127.0.0.1:5000:5000 \ -v /Volumes/MyExternal/temp/frb-mobile-registry:/var/lib/registry \ registry:2 ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_package_native_assets/example/windows/CMakeLists.txt Installs any bundled plugin libraries to the library directory within the application bundle, if they exist. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Installation Rules for Executable and Assets Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_via_create_native_assets/windows/CMakeLists.txt Configures the installation process for the application executable, Flutter ICU data, libraries, bundled plugins, and native assets. It ensures files are placed correctly for runtime execution. ```cmake # === Installation === # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Application Target and Data Files Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/gallery/linux/CMakeLists.txt Installs the application executable to the bundle's root, along with Flutter ICU data and the main Flutter library. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Configure Installation Prefix for Bundled Files Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_package_native_assets/example/windows/CMakeLists.txt Sets the installation prefix to be next to the executable for bundled files, ensuring the application can run in place. This is particularly for Visual Studio compatibility. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Install Application Bundle Components Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_via_integrate_native_assets/linux/CMakeLists.txt Installs the main executable, ICU data, Flutter library, bundled plugin libraries, and native assets into the application bundle. This ensures all necessary components are correctly placed for runtime. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Prepare Repository and VM Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/manual_tests/frb-local-tart-apple-dev-env.md Run these commands from the repository root to initialize submodules, check versions, and create/start the Tart VM. ```bash git rev-parse --show-toplevel git status --short git submodule update --init --recursive sw_vers tart --version .claude/skills/frb-dev-env/frb_dev_env.py tart info .claude/skills/frb-dev-env/frb_dev_env.py tart create .claude/skills/frb-dev-env/frb_dev_env.py tart start --wait 300 .claude/skills/frb-dev-env/frb_dev_env.py tart ip --wait 180 ``` -------------------------------- ### Setup Dummy Branch and Commit Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/manual_tests/ci-filter-single-matrix-dispatch.md Fetches the latest master, creates a new branch, adds an empty commit, and pushes it to origin. This prepares the environment for manual CI testing. ```bash git fetch origin master git switch -c codex/ci-filter-dummy-YYYYMMDD-HHMMSS origin/master git status --short git submodule update --init --recursive ``` ```bash git fetch origin master git switch -c codex/ci-filter-dummy-YYYYMMDD-HHMMSS origin/master git commit --allow-empty -m "Create dummy PR for CI filter manual test" git status --short git push -u origin codex/ci-filter-dummy-YYYYMMDD-HHMMSS ``` -------------------------------- ### Installation Rules for Windows Executable Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_package/example/windows/CMakeLists.txt Configures installation rules for the main executable, runtime libraries, ICU data, and native assets. It ensures files are copied to the correct locations for the application to run, especially for Visual Studio builds. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install flutter_rust_bridge Codegen with Cargo-Binstall Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/quickstart.md Installs the flutter_rust_bridge code generator using cargo-binstall for faster installations. ```shell cargo binstall flutter_rust_bridge_codegen ``` -------------------------------- ### Initialize and Manage VMware Windows Environment Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/vmware_windows/README.md Use these commands to initialize the environment, check host compatibility, perform self-tests, prepare the base ISO, build the VM image, add it as a Vagrant box, and start/upload/test the VM. ```bash tools/vmware_windows/frb_vmware_windows_env.py init-root tools/vmware_windows/frb_vmware_windows_env.py check-host tools/vmware_windows/frb_vmware_windows_env.py self-test tools/vmware_windows/frb_vmware_windows_env.py packer-init tools/vmware_windows/frb_vmware_windows_env.py prepare-iso \ --iso /path/to/frb-windows-vmware/downloads/iso/Windows11_Arm64.iso tools/vmware_windows/frb_vmware_windows_env.py packer-build tools/vmware_windows/frb_vmware_windows_env.py vagrant-box-add \ --box-file /path/to/frb-windows-vmware/packer/boxes/frb-windows11-arm64.box tools/vmware_windows/frb_vmware_windows_env.py start tools/vmware_windows/frb_vmware_windows_env.py upload tools/vmware_windows/frb_vmware_windows_env.py test-flutter-windows --package frb_example/flutter_via_create ``` -------------------------------- ### Install Melos Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/integrate/07-library/01-overview/01-setup.md Use this command to install Melos, a tool for managing Dart/Flutter monorepos, after installing Dart/Flutter. ```bash dart pub global activate melos ``` -------------------------------- ### Install Native Assets Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_via_create_native_assets/linux/CMakeLists.txt Installs native assets provided by build.dart into the installation bundle's library directory. ```cmake # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Initialize and Build VMware Windows VM Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/vmware_windows/README.md These commands initialize the environment, prepare the Windows ISO, and build the VM using Packer. ```bash tools/vmware_windows/frb_vmware_windows_env.py packer-init tools/vmware_windows/frb_vmware_windows_env.py prepare-iso tools/vmware_windows/frb_vmware_windows_env.py packer-build ``` -------------------------------- ### Install LLVM on macOS Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/ffigen-troubleshooting.md Use Homebrew to install LLVM on macOS. Ensure Xcode and its command line tools are installed first. ```bash brew install llvm ``` -------------------------------- ### Project Setup and Basic Configuration Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_via_create_native_assets/windows/CMakeLists.txt Initializes the CMake project, sets the minimum required version, defines the project name, and configures the executable name. It also opts into modern CMake behaviors. ```cmake cmake_minimum_required(VERSION 3.14) project(flutter_via_create_native_assets LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "flutter_via_create_native_assets") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(VERSION 3.14...3.25) ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_package_native_assets/example/linux/CMakeLists.txt Initializes the CMake build system, sets the minimum required version, and defines the project name and languages. ```cmake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) ``` -------------------------------- ### Unwrap Example Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/guides/contributing/submodules/dart-opaque.md Example of unwrapping a Dart opaque object in Rust. ```rust /// [DartWrapObject] can be safely retrieved on a dart thread. pub fn unwrap_dart_opaque(opaque: DartOpaque) -> SyncReturn { let handle = opaque.try_unwrap().unwrap(); SyncReturn("Test".to_owned()) } /// [DartWrapObject] cannot be obtained /// on a thread other than the thread it was created on. pub fn panic_unwrap_dart_opaque(opaque: DartOpaque) { let handle = opaque.try_unwrap().unwrap(); } ``` ```dart // Rust gets (drop safely) wrap Dart_PersistentHandler (or JsValue). api.unwrapDartOpaque(opaque: () => 'Test_String'); // We get an error because DartOpaque was passed to another thread. await expectLater(() => api.panicUnwrapDartOpaque(opaque: () => 'Test_String'), throwsA(isA())); ``` -------------------------------- ### Prepare Repository and Environment Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/manual_tests/frb-local-android-host-runtime-dev-env.md Run these commands from the repository root to update submodules and check system information. ```bash git rev-parse --show-toplevel git status --short git submodule update --init --recursive sw_vers which adb adb version .claude/skills/frb-dev-env/frb_dev_env.py docker info .claude/skills/frb-dev-env/frb_dev_env.py docker create ``` -------------------------------- ### FFI Platform-Agnostic Setup Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/integrate/07-library/02-creating-libraries/02-flutter-wrapper.md This file sets up the FFI implementation by conditionally importing the correct platform-specific file (`io.dart` or `web.dart`) based on the Dart library. ```dart // lib/src/ffi.dart import 'package:library_name/library_name.dart'; import 'ffi/stub.dart' if (dart.library.io) 'ffi/io.dart' if (dart.library.js_interop) 'ffi/web.dart'; LibraryName createLib() => createWrapper(createLibraryImpl()); ``` -------------------------------- ### Install flutter_rust_bridge Codegen Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/quickstart.md Installs the flutter_rust_bridge code generator using Cargo. ```shell cargo install flutter_rust_bridge_codegen ``` -------------------------------- ### Initialize Build Script Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/integrate/07-library/03-platform-setup/01-windows-and-linux.md Basic shell script structure for setting up the build directory. ```bash #!/bin/bash # Setup BUILD_DIR=platform-build mkdir $BUILD_DIR cd $BUILD_DIR ``` -------------------------------- ### Initialize and Prepare Docker Environment Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/manual_tests/frb-local-docker-dev-env.md Run these commands from the repository root to prepare the Docker environment. This includes updating git submodules and checking Docker status. ```bash git rev-parse --show-toplevel git status --short git submodule update --init --recursive docker version .claude/skills/frb-dev-env/frb_dev_env.py docker info .claude/skills/frb-dev-env/frb_dev_env.py docker create ``` -------------------------------- ### User Call Example Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/guides/contributing/overview.md Example of a user invoking a Rust function from Dart. ```dart print(f('Hello')); ``` -------------------------------- ### Tart Base VM Preparation Model Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/tart_macos/README.md Illustrates the workflow for building and managing the reusable Tart base VM, starting from a pinned OCI artifact and progressing through Packer builds and smoke tests. ```text ghcr.io/cirruslabs/macos-sonoma-xcode:16.1 -> optional local OCI registry mirror -> packer build ... frb-tart-base-candidate -> smoke test candidate -> promote candidate to frb-tart-base -> tart clone frb-tart-base frb-tart- ``` -------------------------------- ### Drop Example Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/guides/contributing/submodules/dart-opaque.md Example of dropping a Dart opaque object on the Rust side. ```rust pub fn sync_accept_dart_opaque(opaque: DartOpaque) -> SyncReturn { drop(opaque); SyncReturn("test".to_owned()) } pub fn async_accept_dart_opaque(opaque: DartOpaque) { drop(opaque); } ``` ```dart // the closure is safely removed on the Rust side (on another thread) await api.asyncAcceptDartOpaque(opaque: () => 'Test_String'); // the closure is safely removed on the Rust side (on current thread) api.syncAcceptDartOpaque(opaque: () => 'Test_String'); ``` -------------------------------- ### Install Rust Nightly and WASM Target Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/integrate/05-template/01-setup/03-web.md Install the Rust nightly toolchain, the source component, and the WASM target required for web compilation. Also installs wasm-pack via curl or cargo. ```bash rustup toolchain install nightly rustup +nightly component add rust-src rustup +nightly target add wasm32-unknown-unknown # either of these curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh cargo install wasm-pack ``` -------------------------------- ### Install cargo-ndk Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/integrate/06-existing/03-android/01-tasks.md Install the cargo-ndk tool required for cross-compiling Rust code for Android. ```bash cargo install cargo-ndk ``` -------------------------------- ### Create New Project with Multiple Platforms (including OHOS) Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/guides/miscellaneous/harmony-os.md When creating a new project that targets multiple platforms including OHOS, list all desired platforms and use the `--skip-fvm-install` flag if FVM is in use. ```shell flutter_rust_bridge_codegen create my_app --platforms android,ios,ohos --skip-fvm-install ``` -------------------------------- ### Install VMware and Vagrant Tools with Homebrew Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/vmware_windows/README.md Install essential tools like VMware Fusion, Vagrant, Packer, and xorriso using Homebrew. It is recommended to disable auto-update during installation to prevent potential conflicts. ```bash HOMEBREW_NO_AUTO_UPDATE=1 brew install --cask vmware-fusion HOMEBREW_NO_AUTO_UPDATE=1 brew install --cask vagrant HOMEBREW_NO_AUTO_UPDATE=1 brew install --cask vagrant-vmware-utility HOMEBREW_NO_AUTO_UPDATE=1 brew install packer HOMEBREW_NO_AUTO_UPDATE=1 brew install xorriso vagrant plugin install vagrant-vmware-desktop ``` -------------------------------- ### Initialize and Check VMware Windows Environment Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/manual_tests/frb-local-vmware-windows-dev-env.md Run these commands from the repository root to initialize and check the VMware Windows development environment. The `init-root` command sets up the necessary directory structure, `info` displays current configuration, `check-host` verifies host system requirements, and `self-test` performs a comprehensive system check. ```bash git rev-parse --show-toplevel git status --short git submodule status --recursive tools/vmware_windows/frb_vmware_windows_env.py init-root tools/vmware_windows/frb_vmware_windows_env.py info tools/vmware_windows/frb_vmware_windows_env.py check-host tools/vmware_windows/frb_vmware_windows_env.py self-test tools/vmware_windows/validate_offline.zsh ``` -------------------------------- ### Flutter Assets and AOT Library Installation Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_via_create_native_assets/windows/CMakeLists.txt Manages the installation of Flutter assets and the Ahead-Of-Time (AOT) compiled library. It ensures assets are correctly placed and the AOT library is installed only for Profile and Release builds. ```cmake # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Conditionally Install AOT Library Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/gallery/linux/CMakeLists.txt Installs the AOT library only when the build type is not set to Debug. ```cmake # Install the AOT library on non-Debug builds only. if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### List Available iOS Simulators Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/manual_tests/frb-local-tart-apple-dev-env.md Lists all available iOS simulators within the Tart VM to help identify a suitable simulator for testing. The output should be used to select a bootable UDID. ```bash .claude/skills/frb-dev-env/frb_dev_env.py tart exec -- xcrun simctl list devices available ``` -------------------------------- ### Loop Back Example Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/guides/contributing/submodules/dart-opaque.md Example of passing a Dart opaque object through Rust and back to Dart. ```rust pub fn loop_back(opaque: DartOpaque) -> DartOpaque { opaque } ``` ```dart String f() => 'Test_String'; var fn = await api.loopBack(opaque: f) as String Function(); expect(fn(), 'Test_String'); ``` -------------------------------- ### Build and Import VMware Windows Base Box (Preflight) Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/manual_tests/frb-local-vmware-windows-dev-env.md This command initiates the build process for the Windows VM base box using Packer, but only performs preflight checks without creating the actual VM image. Ensure the ISO path is correctly specified. ```bash tools/vmware_windows/run_packer_build.zsh \ --iso /path/to/frb-windows-vmware/downloads/iso/Windows11_Arm64.iso \ --preflight-only ``` -------------------------------- ### Install Build Dependencies Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/integrate/07-library/03-platform-setup/01-windows-and-linux.md Installs cargo-zigbuild and cargo-xwin, essential for cross-compiling Rust code for different platforms. ```bash cargo install cargo-zigbuild ``` ```bash cargo install cargo-xwin ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_codegen/assets/integration_template/cargokit/plugin/ohos/src/main/cpp/CMakeLists.txt Sets the minimum CMake version, project name, and target library directory. This is standard boilerplate for CMake projects. ```cmake cmake_minimum_required(VERSION 3.10) # Project-level configuration. set(PROJECT_NAME "REPLACE_ME_RUST_CRATE_NAME") set(TARGET_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/${OHOS_ARCH}) project(${PROJECT_NAME} LANGUAGES CXX) ``` -------------------------------- ### Dart Package Creation and Setup Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/integrate/07-library/02-creating-libraries/01-dart-only.md Creates a new Dart package and adds necessary dependencies like flutter_rust_bridge and ffigen. It also sets up FFI stub, IO, and Web implementations for the Dart side. ```bash DART_BASE=packages/$LIBNAME dart create --template=package $DART_BASE (cd $DART_BASE && dart pub add flutter_rust_bridge ffi && dart pub add ffigen --dev) rm $DART_BASE/analysis_options.yaml # we provide our own in repo root ( # ffi setup cd $DART_BASE mkdir -p lib/src/ffi cat << EOF >> lib/src/ffi/stub.dart import 'package:$LIBNAME/src/bridge_generated.dart'; /// Represents the external library for $LIBNAME /// /// Will be a DynamicLibrary for dart:io or WasmModule for dart:html typedef ExternalLibrary = Object; $DART_CLASS_NAME createWrapperImpl(ExternalLibrary lib) => throw UnimplementedError(); EOF cat << EOF >> lib/src/ffi/io.dart import 'dart:ffi'; import 'package:$LIBNAME/src/bridge_generated.dart'; typedef ExternalLibrary = DynamicLibrary; $DART_CLASS_NAME createWrapperImpl(ExternalLibrary dylib) => ${DART_CLASS_NAME}Impl(dylib); EOF cat << EOF >> lib/src/ffi/web.dart import 'package:$LIBNAME/src/bridge_generated.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; typedef ExternalLibrary = WasmModule; $DART_CLASS_NAME createWrapperImpl(ExternalLibrary module) => ${DART_CLASS_NAME}Impl.wasm(module); EOF cat << EOF >> lib/src/ffi.dart import 'bridge_generated.dart'; import 'ffi/stub.dart' if (dart.library.io) 'ffi/io.dart' if (dart.library.js_interop) 'ffi/web.dart'; $DART_CLASS_NAME? _wrapper; $DART_CLASS_NAME createWrapper(ExternalLibrary lib) { _wrapper ??= createWrapperImpl(lib); return _wrapper!; } EOF echo "export 'src/ffi.dart';" >> lib/$LIBNAME.dart ) ``` -------------------------------- ### Specify Integration Backend with create Command Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/integrate/02-builtin.md Demonstrates how to use the `create` command with different integration backends. Use `cargokit` for default behavior or older Flutter/Dart versions, and `native-assets` for projects supporting build hooks and code assets. ```bash flutter_rust_bridge_codegen create my_app --integration-backend cargokit flutter_rust_bridge_codegen create my_app --integration-backend native-assets ``` -------------------------------- ### Install AOT Library Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_via_integrate/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library, but only for Profile and Release build configurations. ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Build VMware Windows VM with GUI Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/vmware_windows/README.md Build the VMware Windows VM, running in GUI mode to display any necessary prompts from VMware Fusion. ```bash tools/vmware_windows/frb_vmware_windows_env.py packer-build --gui \ --iso /path/to/frb-windows-vmware/downloads/iso/Windows11_Arm64.iso ``` -------------------------------- ### Record Windows and Toolchain Versions Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/manual_tests/frb-local-vmware-windows-dev-env.md Executes a command within the VM to capture system and toolchain versions for verification. ```bash tools/vmware_windows/frb_vmware_windows_env.py exec -- powershell -NoProfile -Command "Get-ComputerInfo | Select-Object WindowsProductName,OsArchitecture,WindowsVersion; flutter --version; dart --version; rustc --version; cargo --version; cmake --version; ninja --version" ``` -------------------------------- ### Install cargo-ndk Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/manual/miscellaneous/92-archived/02-tutorial-with-flutter/03-alternative-ndk.md Install `cargo-ndk` version 2.7.0 or above. This version is compatible with Android NDK versions greater than 22. ```bash cargo install cargo-ndk --version ^2.7.0 ``` -------------------------------- ### Initialize and Build Packer VM Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/tools/tart_macos/README.md Initializes Packer and builds a candidate base VM from a source VM. Ensure to keep the flutter_version in sync with CI configurations. ```bash cd tools/tart_macos/packer packer init . packer build \ -var 'source_vm=127.0.0.1:5000/cirruslabs/macos-sonoma-xcode:16.1' \ -var 'target_vm=frb-tart-base-candidate' \ -var 'flutter_version=3.44.0' \ -var 'host_proxy_url=http://192.168.64.1:7897' \ -var 'allow_insecure=true' \ . ``` -------------------------------- ### Install Native Assets Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_package_native_assets/example/linux/CMakeLists.txt Copies native assets provided by build.dart from all packages into the library directory of the installation bundle. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Library Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_package_native_assets/example/windows/CMakeLists.txt Installs the main Flutter library file to the library directory within the application bundle. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Initialize Rust Library with Custom Parameters Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/guides/custom/dart/constructors.md Use this method to initialize the library with specific configuration parameters during startup. ```dart await RustLib.init(someCustomizableParameter: someValue); ``` -------------------------------- ### Install ICU Data File Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_package_native_assets/example/windows/CMakeLists.txt Installs the ICU data file to the data directory within the application bundle. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install AOT Library Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_package_native_assets/example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library to the data directory, but only for Profile and Release build configurations. ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Reverse iOS Build Phase setup Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/guides/miscellaneous/upgrade/v2.md If you used a specific build phase for iOS integration, reverse those steps. This might involve removing an old Build Phase or deleting a script_phase in your Podfile. ```bash For the iOS setup, you need to reverse the setup steps you did by either removing the old Build Phase (if using method 1) or deleting the script_phase in your `Podfile` (if using method 2). ``` -------------------------------- ### Install Native Assets Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_example/flutter_via_integrate/windows/CMakeLists.txt Installs native assets provided by the build.dart script from all packages into the application's runtime directory. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Integrate V2 boilerplate Source: https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/website/docs/guides/miscellaneous/upgrade/v2.md Run this command to integrate V2 boilerplate into your existing project. This is usually the first step in the upgrade process. ```bash flutter_rust_bridge_codegen integrate ```