Logofpack

Targets and artifacts

What every target builds, where it runs, which tools it needs, and how artifacts are named.

目标与产物

每个目标产出什么、在哪里构建、需要哪些工具。

Fifteen targets in six platforms. For a walk-through of each platform see the tutorials: Android, iOS, macOS, Windows, Linux, Web.

The default file name template is {app}{-flavor}-{version}{+build}-{platform}{-arch}{-variant}{-mode} (no mode for release).

TargetHost OSArtifactTools
apk any -android-universal.apk, -android-arm64-v8a.apk … flutter, apksigner (signature check)
aab any -android.aab flutter, keytool (signature check)
ipa macOS -ios-arm64.ipa (unsigned: -ios-arm64-unsigned.ipa) flutter/xcodebuild, ditto with --no-codesign
macos macOS -macos-universal.zip flutter, codesign, ditto, notarytool
dmg macOS -macos-universal.dmg hdiutil or create-dmg, codesign, notarytool, stapler
pkg macOS -macos.pkg pkgbuild + productbuild (installs to /Applications), Developer ID Installer signing, notarytool, stapler
windows Windows -windows-x64-portable.zip flutter
exe Windows -windows-x64-setup.exe Inno Setup (ISCC)
msix Windows -windows-x64.msix the msix dev dependency (dart run msix:create)
linuxLinux-linux-x64.tar.gzflutter
debLinux-linux-x64.debdpkg-deb
rpmLinux-linux-x64.rpmrpmbuild
appimage Linux -linux-x64.AppImage appimagetool (skipped by --all when missing)
snap Linux -linux-x64.snap snapcraft (skipped by --all when missing)
webany-web.zipflutter

Flutter cannot cross-compile iOS/macOS/Windows/Linux desktop apps. fpack build --all skips targets this machine cannot build and says why; naming one explicitly (e.g. fpack build ipa on Linux) is an error that points you to a CI runner of that OS. --dry-run still shows a reference plan for such targets.

One flutter build is shared per run: macos + dmg + pkg build once, linux + deb + rpm + appimage + snap build once, windows + exe + msix build once.

Target aliases work on the command line and in build.targets: bundle/appbundle → aab, android → apk, ios → ipa, mac/osx/app → macos, win/zip/portable → windows, setup/installer/inno → exe, tar/tgz/tar.gz → linux, debian → deb, fedora → rpm, image/AppImage → appimage, snapcraft → snap.

fpack doctor lists a target as "ready to build" only when nothing it needs is missing; for apk/aab that includes Java (JDK 17+), even though a build still tries without it (Gradle may find a JDK fpack cannot see).

共 15 个目标,分属 6 个平台。每个平台的完整流程见教程:Android、iOS、macOS、Windows、Linux、Web。

文件名模板默认为 {app}{-flavor}-{version}{+build}-{platform}{-arch}{-variant}{-mode}(release 模式不带 mode)。

目标需要的系统产物使用的工具
apk 任意 -android-universal.apk、-android-arm64-v8a.apk … flutter、apksigner(校验签名)
aab任意-android.aabflutter、keytool(校验签名)
ipa macOS -ios-arm64.ipa(未签名:-ios-arm64-unsigned.ipa) flutter/xcodebuild,--no-codesign 时用 ditto
macos macOS -macos-universal.zip flutter、codesign、ditto、notarytool
dmg macOS -macos-universal.dmg hdiutil 或 create-dmg、codesign、notarytool、stapler
pkg macOS -macos.pkg pkgbuild + productbuild(安装到 /Applications)、Developer ID Installer 签名、notarytool、stapler
windows Windows -windows-x64-portable.zip flutter
exe Windows -windows-x64-setup.exe Inno Setup(ISCC)
msix Windows -windows-x64.msix msix dev 依赖(dart run msix:create)
linuxLinux-linux-x64.tar.gzflutter
debLinux-linux-x64.debdpkg-deb
rpmLinux-linux-x64.rpmrpmbuild
appimage Linux -linux-x64.AppImage appimagetool(--all 时缺失则跳过)
snap Linux -linux-x64.snap snapcraft(--all 时缺失则跳过)
web任意-web.zipflutter

Flutter 不能跨系统编译 iOS/macOS/Windows/Linux 桌面应用。fpack build --all 会跳过本机不能构建的目标并说明原因;显式指定时(如在 Linux 上 fpack build ipa)会报错并提示用对应系统的 CI 机器。--dry-run 下仍会显示这类目标的参考计划。

同一次运行中共享 flutter 构建:macos + dmg + pkg 只构建一次,linux + deb + rpm + appimage + snap 只构建一次,windows + exe + msix 只构建一次。

命令行和 build.targets 都接受目标别名:bundle/appbundle → aab,android → apk,ios → ipa,mac/osx/app → macos,win/zip/portable → windows,setup/installer/inno → exe,tar/tgz/tar.gz → linux,debian → deb,fedora → rpm,image/AppImage → appimage,snapcraft → snap。

fpack doctor 只有在所需工具齐全时才把目标列为“当前可构建”;对 apk/aab 来说包括 Java(JDK 17+)——不过没有检测到 Java 时构建仍会尝试(Gradle 可能找到 fpack 看不到的 JDK)。