App Store
Apple App Store 是由苹果维护的应用商店。你可以通过这个应用商店分发面向 macOS 和 iOS 的 Tauri 应用。
🌐 The Apple App Store is the app marketplace maintained by Apple. You can distribute your Tauri app targeting macOS and iOS via this App Store.
本指南仅涵盖将应用直接分发到 App Store 的详细信息。有关 macOS 分发选项和配置的更多信息,请参阅通用 App Bundle。
🌐 This guide only covers details for distributing apps directly to the App Store. See the general App Bundle for more information on macOS distribution options and configurations.
🌐 Requirements
分发 iOS 和 macOS 应用需要注册 Apple Developer 计划。
🌐 Distributing iOS and macOS apps requires enrolling to the Apple Developer program.
🌐 Additionally, you must setup code signing for macOS and iOS.
🌐 Changing App Icon
在运行 tauri ios init 设置 Xcode 项目之后,你可以使用 tauri icon 命令来更新应用图标。
🌐 After running tauri ios init to setup the Xcode project, you can use the tauri icon command to update the app icons.
npm run tauri icon /path/to/app-icon.png -- --ios-color '#fff'yarn tauri icon /path/to/app-icon.png --ios-color '#fff'pnpm tauri icon /path/to/app-icon.png --ios-color '#fff'deno task tauri icon /path/to/app-icon.png --ios-color '#fff'bun tauri icon /path/to/app-icon.png --ios-color '#fff'cargo tauri icon /path/to/app-icon.png --ios-color '#fff'--ios-color 参数定义了 iOS 图标的背景颜色。
🌐 The --ios-color argument defines the background color for the iOS icons.
🌐 Setting up
在加入苹果开发者计划后,将你的 Tauri 应用分发到 App Store 的第一步是将你的应用注册到 App Store 连接。
🌐 After enrolling to the Apple Developer program, the first step to distribute your Tauri app in the App Store is to register your app in the App Store Connect.
🌐 Build and upload
Tauri CLI 可以为 macOS 和 iOS 打包你的应用。必须在 macOS 机器上运行。
🌐 The Tauri CLI can package your app for macOS and iOS. Running on a macOS machine is a requirement.
Tauri 从 [tauri.conf.json > version] 中定义的值派生 CFBundleVersion。
如果你需要不同的打包版本方案,例如顺序编码,你可以在 [tauri.conf.json > bundle > iOS > bundleVersion] 或 [tauri.conf.json > bundle > macOS > bundleVersion] 配置中设置自定义打包版本:
🌐 Tauri derives the CFBundleVersion from the value defined in [tauri.conf.json > version].
You can set a custom bundle version in the [tauri.conf.json > bundle > iOS > bundleVersion] or [tauri.conf.json > bundle > macOS > bundleVersion] configuration
if you need a different bundle version scheme e.g. sequential codes:
{ "bundle": { "iOS": { "bundleVersion": "100" } }}请注意,Tauri 使用 Xcode 来开发 iOS 应用,因此你可以使用 Xcode 来归档和分发 iOS 应用,而不是使用 Tauri CLI。要在 Xcode 中打开 iOS 项目进行构建,你必须运行以下命令:
🌐 Note that Tauri leverages Xcode for the iOS app so you can use Xcode to archive and distribute for iOS instead of the Tauri CLI. To open the iOS project in Xcode for building you must run the following command:
npm run tauri ios build -- --openyarn tauri ios build --openpnpm tauri ios build --opendeno task tauri ios build --openbun tauri ios build --opencargo tauri ios build --open要将你的应用上传到 App Store,首先必须确保设置了所有必需的配置选项,这样你才能打包应用包,创建已签名的 .pkg 文件并进行上传。
🌐 To upload your app to the App Store, first you must ensure all required configuration options are set
so you can package the App Bundle, create a signed .pkg file and upload it.
以下部分将指导你完成整个过程。
🌐 The following sections will guide you through the process.
🌐 Setup
你的应用必须包含一些配置才能被 App Store 验证系统接受。
🌐 Your app must include some configurations to be accepted by the App Store verification system.
- 类别
你的应用必须定义其 tauri.conf.json > bundle > category 以在 App Store 中显示:
🌐 Your app must define its tauri.conf.json > bundle > category to be displayed in the App Store:
{ "bundle": { "category": "Utility" }}- 配置文件
你还必须为你的应用创建一个配置文件,以便 Apple 接受。
🌐 You must also create a provisioning profile for your app to be accepted by Apple.
在 Identifiers 页面,创建一个新的应用 ID,并确保其 “Bundle ID” 值与 tauri.conf.json > identifier 中设置的标识符匹配。
🌐 In the Identifiers page,
create a new App ID and make sure its “Bundle ID” value matches the identifier set in tauri.conf.json > identifier.
导航到Profiles页面以创建新的配置文件。 对于 App Store macOS 分发,它必须是“Mac App Store Connect”配置文件。 选择合适的 App ID,并关联你用于代码签名的证书。
🌐 Navigate to the Profiles page to create a new provisioning profile. For App Store macOS distribution, it must be a “Mac App Store Connect” profile. Select the appropriate App ID and link the certificate you are using for code signing.
创建配置文件后,下载它并将其保存到已知位置并配置 Tauri 以将其包含在你的应用包中:
🌐 After creating the provisioning profile, download it and save it to a known location and configure Tauri to include it in your app bundle:
{ "bundle": { "macOS": { "files": { "embedded.provisionprofile": "path/to/profile-name.provisionprofile" } } }}- Info.plist
你的应用必须遵守加密出口法规。请参阅官方文档以获取更多信息。
🌐 Your app must comply with encryption export regulations. See the official documentation for more information.
在 src-tauri 文件夹中创建一个 Info.plist 文件:
🌐 Create a Info.plist file in the src-tauri folder:
<?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 Store 分发。此外,你还必须在代码签名权限中设置你的应用 ID 和团队 ID。
🌐 Your app must include the App Sandbox capability to be distributed in the App Store. Additionally, you must also set your App ID and Team ID in the code signing entitlements.
在 src-tauri 文件夹中创建一个 Entitlements.plist 文件:
🌐 Create a Entitlements.plist file in the src-tauri folder:
<?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 开发者团队 ID,该 ID 可以在你为配置文件创建的 标识符 的 App ID Prefix 部分找到。
🌐 Note that you must replace $IDENTIFIER with the tauri.conf.json > identifier value
and $TEAM_ID with your Apple Developer team ID, which can be found in the App ID Prefix section in the
Identifier you created for the provisioning profile.
并在 macOS 包配置 tauri.conf.json > bundle > macOS > entitlements 中引用该文件:
🌐 And reference that file in the macOS bundle configuration tauri.conf.json > bundle > macOS > entitlements:
{ "bundle": { "macOS": { "entitlements": "./Entitlements.plist" } }}现在,你必须在启用代码签名的情况下构建应用才能应用权利。
🌐 You now must build your application with code signing enabled for the entitlements to apply.
确保你的应用在应用沙盒上下文中运行时可以正常工作。
🌐 Make sure your app works when running in an App Sandbox context.
🌐 Build
你必须将你的 macOS 应用作为 .pkg 文件上传到 App Store。
运行以下命令将你的应用打包为 macOS 应用打包包(.app 扩展名):
🌐 You must upload your macOS application as a .pkg file to the App Store.
Run the following command to package your app as a macOS App Bundle (.app extension):
tauri build --bundles app --target universal-apple-darwin有关配置选项的更多信息,请参阅 [应用包分发指南]。
🌐 See the App Bundle distribution guide for more information on configuration options.
要从你的应用包生成签名的 .pkg,请运行以下命令:
🌐 To generate a signed .pkg from your app bundle, run the following command:
xcrun productbuild --sign "<certificate signing identity>" --component "target/universal-apple-darwin/release/bundle/macos/$APPNAME.app" /Applications "$APPNAME.pkg"请注意,你必须将 $APPNAME 替换为你的应用名称。
🌐 Note that you must replace $APPNAME with your app name.
🌐 Upload
现在你可以使用 altool CLI 将你的应用 PKG 上传到 App Store:
🌐 Now you can use the altool CLI to upload your app PKG to the 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 密钥来上传你的应用。有关更多信息,请参阅[身份验证部分]。
🌐 Note that altool requires an App Store Connect API key to upload your app.
See the authentication section for more information.
然后,你的应用将由 Apple 验证,如果获得批准,则可在 TestFlight 中获取。
🌐 Your app will then be validated by Apple and available in TestFlight if approved.
要构建你的 iOS 应用,请运行 tauri ios build 命令:
🌐 To build your iOS app, run the tauri ios build command:
npm run tauri ios build -- --export-method app-store-connectyarn tauri ios build --export-method app-store-connectpnpm tauri ios build --export-method app-store-connectdeno task tauri ios build --export-method app-store-connectbun tauri ios build --export-method app-store-connectcargo tauri ios build --export-method app-store-connect生成的 IPA 文件可以在 src-tauri/gen/apple/build/arm64/$APPNAME.ipa 中找到。
🌐 The generated IPA file can be found in src-tauri/gen/apple/build/arm64/$APPNAME.ipa.
请注意,你必须将 $APPNAME 替换为你的应用名称。
🌐 Note that you must replace $APPNAME with your app name.
现在你可以使用 altool CLI 将你的 iOS 应用上传到 App Store:
🌐 Now you can use the altool CLI to upload your iOS app to the 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 密钥来上传你的应用。有关更多信息,请参阅[身份验证部分]。
🌐 Note that altool requires an App Store Connect API key to upload your app.
See the authentication section for more information.
然后,你的应用将由 Apple 验证,如果获得批准,则可在 TestFlight 中获取。
🌐 Your app will then be validated by Apple and available in TestFlight if approved.
🌐 Authentication
iOS 和 macOS 应用是使用 altool 上传的,altool 使用 App Store Connect API 密钥进行身份验证。
🌐 The iOS and macOS apps are uploaded using altool, which uses an App Store Connect API key to authenticate.
要创建一个新的 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。
Tauri 中文网 - 粤ICP备13048890号
Nodejs.cn 旗下网站