跳到内容
Tauri

应用商店

Apple App Store 是由 Apple 维护的应用市场。您可以通过此 App Store 发布针对 macOS 和 iOS 的 Tauri 应用。

本指南仅涵盖直接向 App Store 发布应用的详细信息。有关 macOS 发布选项和配置的更多信息,请参阅通用应用捆绑包

分发 iOS 和 macOS 应用需要注册 Apple Developer 计划。

此外,您必须为 macOSiOS 设置代码签名。

运行 tauri ios init 设置 Xcode 项目后,您可以使用 tauri icon 命令更新应用图标。

npm run tauri icon /path/to/app-icon.png -- --ios-color #fff

--ios-color 参数定义 iOS 图标的背景颜色。

在注册 Apple Developer 计划后,在 App Store 中分发 Tauri 应用的第一步是在 App Store Connect 中注册您的应用。

Tauri CLI 可以为 macOS 和 iOS 打包您的应用程序。需要在 macOS 机器上运行。

Tauri 从 [tauri.conf.json > version] 中定义的值派生 CFBundleVersion。如果您需要不同的捆绑版本方案(例如顺序代码),您可以在 [tauri.conf.json > bundle > iOS > bundleVersion] 或 [tauri.conf.json > bundle > macOS > bundleVersion] 配置中设置自定义捆绑版本。

tauri.conf.json
{
"bundle": {
"iOS": {
"bundleVersion": "100"
}
}
}

请注意,Tauri 利用 Xcode 进行 iOS 应用开发,因此您可以使用 Xcode 来归档和分发 iOS 应用,而不是使用 Tauri CLI。要在 Xcode 中打开 iOS 项目进行构建,您必须运行以下命令

npm run tauri ios build -- --open

要将您的应用程序上传到 App Store,首先必须确保所有必需的配置选项都已设置,以便您可以打包应用程序捆绑包,创建已签名的 .pkg 文件并上传它。

以下部分将引导您完成该过程。

您的应用必须包含一些配置,才能被 App Store 验证系统接受。

  • 类别

您的应用程序必须定义其tauri.conf.json > bundle > category才能在 App Store 中显示

tauri.conf.json
{
"bundle": {
"category": "Utility"
}
}
  • 预置描述文件

您还必须为您的应用创建预置描述文件,才能被 Apple 接受。

Identifiers 页面,创建一个新的 App ID,并确保其“Bundle ID”值与 tauri.conf.json > identifier 中设置的标识符匹配。

导航到 Profiles 页面以创建新的预置描述文件。对于 App Store macOS 分发,它必须是“Mac App Store Connect”描述文件。选择相应的 App ID 并链接您用于代码签名的证书。

创建预置描述文件后,下载并保存到已知位置,然后配置 Tauri 将其包含在您的应用捆绑包中

tauri.conf.json
{
"bundle": {
"macOS": {
"files": {
"embedded.provisionprofile": "path/to/profile-name.provisionprofile"
}
}
}
}
  • Info.plist

您的应用程序必须遵守加密出口法规。有关更多信息,请参阅官方文档

在 src-tauri 文件夹中创建一个 Info.plist 文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ITSAppUsesNonExemptEncryption</key>
<false/> # or `true` if your app uses encryption
</dict>
</plist>
  • 授权

您的应用程序必须包含 App Sandbox 功能才能在 App Store 中分发。此外,您还必须在代码签名授权中设置您的 App ID 和 Team ID。

src-tauri 文件夹中创建一个 Entitlements.plist 文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.application-identifier</key>
<string>$TEAM_ID.$IDENTIFIER</string>
<key>com.apple.developer.team-identifier</key>
<string>$TEAM_ID</string>
</dict>
</plist>

请注意,您必须将 $IDENTIFIER 替换为 tauri.conf.json > identifier 值,将 $TEAM_ID 替换为您的 Apple Developer 团队 ID,该 ID 可以在您为预置描述文件创建的 IdentifierApp ID Prefix 部分中找到。

并在 macOS 捆绑包配置 tauri.conf.json > bundle > macOS > entitlements 中引用该文件

tauri.conf.json
{
"bundle": {
"macOS": {
"entitlements": "./Entitlements.plist"
}
}
}

您现在必须启用代码签名来构建您的应用程序,以便授权生效。

确保您的应用程序在 App Sandbox 环境中运行时正常工作。

您必须将 macOS 应用程序作为 .pkg 文件上传到 App Store。运行以下命令将您的应用程序打包为 macOS 应用程序捆绑包(.app 扩展名)

tauri build --bundles app --target universal-apple-darwin

有关配置选项的更多信息,请参阅 应用捆绑分发指南

要从您的应用程序捆绑包生成已签名的 .pkg,请运行以下命令

xcrun productbuild --sign "<certificate signing identity>" --component "target/universal-apple-darwin/release/bundle/macos/$APPNAME.app" /Applications "$APPNAME.pkg"

请注意,您必须将 *\$APPNAME* 替换为您的应用程序名称。

现在您可以使用 altool CLI 将您的应用 PKG 上传到 App Store

xcrun altool --upload-app --type macos --file "$APPNAME.pkg" --apiKey $APPLE_API_KEY_ID --apiIssuer $APPLE_API_ISSUER

请注意,altool 需要 App Store Connect API 密钥才能上传您的应用。有关更多信息,请参阅身份验证部分

您的应用将由 Apple 验证,如果获得批准,将在 TestFlight 中提供。

要构建您的 iOS 应用程序,请运行 tauri ios build 命令

npm run tauri ios build -- --export-method app-store-connect

生成的 IPA 文件可在 src-tauri/gen/apple/build/arm64/$APPNAME.ipa 中找到。

请注意,您必须将 *\$APPNAME* 替换为您的应用程序名称。

现在您可以使用 altool CLI 将您的 iOS 应用程序上传到 App Store

xcrun altool --upload-app --type ios --file "src-tauri/gen/apple/build/arm64/$APPNAME.ipa" --apiKey $APPLE_API_KEY_ID --apiIssuer $APPLE_API_ISSUER

请注意,altool 需要 App Store Connect API 密钥才能上传您的应用。有关更多信息,请参阅身份验证部分

您的应用将由 Apple 验证,如果获得批准,将在 TestFlight 中提供。

iOS 和 macOS 应用程序使用 altool 上传,它使用 App Store Connect API 密钥进行身份验证。

要创建新的 API 密钥,请打开 App Store Connect 的用户和访问页面,选择“集成 > 个人密钥”选项卡,点击“添加”按钮,选择名称和“开发者访问权限”。APPLE_API_ISSUER(发行方 ID)显示在密钥表上方,APPLE_API_KEY_ID 是该表中“密钥 ID”列的值。您还需要下载私钥,该操作只能执行一次,并且仅在页面重新加载后才可见(按钮显示在新创建的密钥的表格行上)。私钥文件路径必须保存为 AuthKey\_<APPLE_API_KEY_ID>.p8 在以下目录之一中:<current-working-directory>/private_keys~/private_keys~/.private_keys~/.appstoreconnect/private_keys


© 2025 Tauri 贡献者。CC-BY / MIT