7 个版本
0.2.3 | 2022 年 9 月 12 日 |
---|---|
0.2.2 | 2022 年 8 月 30 日 |
0.1.3 | 2022 年 2 月 21 日 |
0.1.2 | 2022 年 1 月 9 日 |
#321 in 构建工具
265KB
5.5K SLoC
Crossbundle CLI
crossbundle 是一个命令行工具,它封装了 Android 和 iOS 构建/打包过程中的无聊部分,并帮助移动开发者创建和维护用 rust 编程语言编写的应用程序。
支持状态
构建支持的操作系统(仅限 macOS 上的 iOS)
名称 | 状态 |
---|---|
Windows | ✅ |
Linux | ✅ |
macOS | ✅ |
打包策略状态
名称 | 描述 | 状态 |
---|---|---|
Android APK | 通过 -s=native-apk 标志支持。 |
✅ |
Android AAB | 通过 -s=native-aab 标志支持。 |
✅ |
Android Gradle | 通过 -s=gradle-apk 标志支持。 |
✅ |
Apple Debug APP | 默认构建策略。仅在模拟器上工作,可以用开发证书在 iPhone 上运行。 | ✅ |
Apple Debug IPA | 仅在模拟器上工作,可以用开发证书在 iPhone 上运行。 | 🆗 |
Apple Release IPA | 尚未支持。Crossbundle 应生成 xcodeproj ,但用户需要手动构建和签名 IPA。 |
🛠 |
支持的游戏引擎
名称 | 描述 | 状态 |
---|---|---|
Bevy | 默认构建方法。将 ndk-glue 注入生成的临时 lib.rs 文件。 |
🆗 |
Macroquad | 通过 Cargo.toml 元数据中的 app_wrapper = "quad" 支持。也可以作为 cargo-quad-apk 使用,但具有所有 crossbundle 功能。 |
✅ |
占位符 | 这里没有找到您的游戏引擎?请提交问题!我们很高兴为新的引擎添加支持。 | 🛠 |
✅ = 正常工作并经过测试 — 🆗 = 可以工作,可能包含错误 — 🛠 = 正在开发中
安装
cargo install --git=https://github.com/dodorare/crossbow crossbundle
有关如何在您的平台上设置环境的更多详细信息,请参阅安装文档。
Cargo.toml元数据语法
[[package.metadata]]
# Cross-platform user-friendly application name for your app.
app_name = "Example"
# Cross-platform assets directory path relatively to project path.
assets = ["assets"]
# Cross-platform icon path to generate icons for Android and iOS.
icon = "../../assets/images/icon.png"
[[package.metadata.android]]
# Android application wrapper: supports ndk-glue and quad
app_wrapper = "quad"
# The user-friendly application name for your app. Displayed in the applications menu
app_name = "Example"
# Path to AndroidManifest.xml file
manifest_path = "path/to/AndroidManifest.xml"
# Android resources directory path relatively to project path.
resources = ["res/android"]
# Android assets directory path relatively to project path.
assets = ["assets"]
# Android targets to build on debug or release.
debug_build_targets = ["aarch64-linux-android"]
release_build_targets = ["aarch64-linux-android"]
# Complete support of ALL AndroidManifest.xml attributes
[package.metadata.android.manifest]
package = "com.example.ExampleProject"
# Adds a uses-permission element to the AndroidManifest.xml.
# Note that android_version 23 and higher, Android requires the application to request permissions at runtime.
[[package.metadata.android.manifest.uses_permission]]
name = "android.permission.INTERNET"
# Specifies that an app wants a particular permission, but only if the app is installed on a device running
# Android 6.0 (API level 23) or higher. If the device is running API level 22 or lower, the app does not have the specified permission.
#
# See https://developer.android.com.cn/guide/topics/manifest/uses-permission-sdk-23-element
[[package.metadata.android.manifest.uses_permission_sdk_23]]
name = "android.permission.WRITE_EXTERNAL_STORAGE"
max_sdk_version = 31
# See https://developer.android.com.cn/guide/topics/manifest/service-element
[[package.metadata.android.manifest.service]]
name = "UpdateService"
intent_filter = []
meta_data = []
# See https://developer.android.com.cn/guide/topics/manifest/queries-element#provider
[[package.metadata.android.manifest.queries.provider]]
authorities = "org.khronos.openxr.runtime_broker;org.khronos.openxr.system_runtime_broker"
# Note: The `name` attribute is normally not required for a queries provider, but is non-optional
# as a workaround for aapt throwing errors about missing `android:name` attribute.
# This will be made optional if/when cargo-apk migrates to aapt2.
name = "org.khronos.openxr"
# See https://developer.android.com.cn/guide/topics/manifest/meta-data-element
[[package.metadata.android.manifest.application.meta_data]]
name = "com.oculus.vr.focusaware"
value = "true"
[package.metadata.apple]
# Apple targets to build on debug or release.
debug_build_targets = ["aarch64-apple-ios"]
release_build_targets = ["aarch64-apple-ios", "x86_64-apple-ios"]
# Apple resources directory path relatively to project path.
resources = ["res/apple"]
CLI选项和标志
要查看每个命令/子命令的完整文档,您可以输入-h
或--help
crossbundle -h
crossbundle build android -h
crossbundle run ios -h
crossbundle install -h
# ...
crossbundle -h
的结果
USAGE:
crossbundle [OPTIONS] <SUBCOMMAND>
OPTIONS:
-c, --current-dir <CURRENT_DIR> The current directory where to run all commands
-h, --help Print help information
-q, --quiet No output printed to stdout
-v, --verbose A level of verbosity, and can be used multiple times
-V, --version Print version information
SUBCOMMANDS:
build Starts the process of building/packaging/signing of the rust crate
help Print this message or the help of the given subcommand(s)
install Installs bundletool and Android Studio's sdkmanager
new Creates a new Cargo package in the given directory. Project will be ready to
build with `crossbundle`
run Executes `build` command and then deploy and launches the application on the
device/emulator
crossbundle run android -h
的结果(此命令扩展了crossbundle build android
)
Executes `build` command and then deploy and launches the application on the Android device/emulator
USAGE:
crossbundle run android [OPTIONS]
OPTIONS:
--all-features
Activate all available features of selected package
--example <EXAMPLE>
Build the specified example
--export-path <EXPORT_PATH>
Path to export Gradle project. By default exports to `target/android/` folder
--features <FEATURES>
Space or comma separated list of features to activate. These features only apply to the
current directory's package. Features of direct dependencies may be enabled with
`<dep-name>/<feature-name>` syntax. This flag may be specified multiple times, which
enables all specified features
-h, --help
Print help information
--lib <LIB>
Only compile rust code as a dynamic library. By default: "crossbow-android"
--log
Enable logging attach after run
--no-default-features
Do not activate the `default` feature of the current directory's package
--release
Build optimized artifact with the `release` profile
-s, --strategy <STRATEGY>
Build strategy specifies what and how to build Android application: with help of Gradle,
or with our native approach [default: gradle-apk]
--sign-key-alias <SIGN_KEY_ALIAS>
Signing key alias
--sign-key-pass <SIGN_KEY_PASS>
Signing key password
--sign-key-path <SIGN_KEY_PATH>
Path to the signing key
-t, --target <TARGET>...
Build for the given android architecture. Supported targets are:
`armv7-linux-androideabi`, `aarch64-linux-android`, `i686-linux-android`,
`x86_64-linux-android`
--target-dir <TARGET_DIR>
Directory for generated artifact and intermediate files
crossbundle build ios -h
的结果(此命令扩展了crossbundle build ios
)
Executes `build` command and then deploy and launches the application on the iOS device/emulator
USAGE:
crossbundle run ios [OPTIONS]
OPTIONS:
--all-features
Activate all available features of selected package
--bin <BIN>
Specify custom cargo binary
-d, --debug
Run in debug mode
-d, --device
Install and launch on the connected device
-D, --device-id <DEVICE_ID>
Connected device id
--example <EXAMPLE>
Build the specified example
--features <FEATURES>
Space or comma separated list of features to activate. These features only apply to the
current directory's package. Features of direct dependencies may be enabled with
`<dep-name>/<feature-name>` syntax. This flag may be specified multiple times, which
enables all specified features
-h, --help
Print help information
--identity <IDENTITY>
The id of the identity used for signing. It won't start the signing process until you
provide this flag
--no-default-features
Do not activate the `default` feature of the current directory's package
--profile-name <PROFILE_NAME>
Provisioning profile name to find in this directory:
`~/Library/MobileDevice/Provisioning\ Profiles/`
--profile-path <PROFILE_PATH>
Absolute path to provisioning profile
--release
Build optimized artifact with the `release` profile
-s, --strategy <STRATEGY>
Build strategy specifies what and how to build iOS application: with help of XCode, or
with our native approach [default: native-ipa]
-s, --simulator-name <SIMULATOR_NAME>
Simulator device name [default: "iPhone 13"]
-t, --target <TARGET>...
Build for the given apple architecture. Supported targets are: `aarch64-apple-ios`,
`aarch64-apple-ios-sim`, `armv7-apple-ios`, `armv7s-apple-ios`, `i386-apple-ios`,
`x86_64-apple-ios`
--target-dir <TARGET_DIR>
Directory for generated artifact and intermediate files
--team-identifier <TEAM_IDENTIFIER>
The team identifier of your signing identity
故障排除
找不到共享库 "<lib_name>"
如果您在apk/aab
中遇到缺少共享库的问题,您可以通过将您的.so
文件放入target/<rust-triple>/<profile>/tools/libname.so
来修复此问题。构建器将拾取库并将其放入最终包中。
许可
根据MIT或Apache-2.0许可。
依赖关系
~62MB
~1M SLoC