Skip to main content

发布到 Apple App Store

发布过程与任何其他原生 iOS 应用相同,但需要考虑一些其他注意事项。

¥The publishing process is the same as any other native iOS app, with some additional considerations to take into account.

信息

如果你正在使用 Expo,请阅读 部署到应用商店 的 Expo 指南来构建你的应用并将其提交到 Apple App Store。本指南可与任何 React Native 应用配合使用,以自动化部署过程。

¥If you are using Expo, read the Expo guide for Deploying to App Stores to build and submit your app for the Apple App Store. This guide works with any React Native app to automate the deployment process.

1. 配置发布方案

¥ Configure release scheme

构建要在 App Store 中分发的应用需要在 Xcode 中使用 Release 方案。为 Release 构建的应用将自动禁用应用内开发菜单,这将防止你的用户无意中访问生产中的菜单。它还会在本地打包 JavaScript,因此你可以将应用放在设备上并在未连接到计算机的情况下进行测试。

¥Building an app for distribution in the App Store requires using the Release scheme in Xcode. Apps built for Release will automatically disable the in-app Dev Menu, which will prevent your users from inadvertently accessing the menu in production. It will also bundle the JavaScript locally, so you can put the app on a device and test whilst not connected to the computer.

要将你的应用配置为使用 Release 方案构建,请转到产品 → 方案 → 编辑方案。选择侧栏中的“运行”选项卡,然后将“构建配置”下拉列表设置为 Release

¥To configure your app to be built using the Release scheme, go to ProductSchemeEdit Scheme. Select the Run tab in the sidebar, then set the Build Configuration dropdown to Release.

专业提示

¥Pro Tips

随着你的应用包大小的增加,你可能会开始看到启动屏幕和根应用视图显示之间出现空白屏幕。如果是这种情况,你可以将以下代码添加到 AppDelegate.m,以便在转换期间保持启动屏幕显示。

¥As your App Bundle grows in size, you may start to see a blank screen flash between your splash screen and the display of your root application view. If this is the case, you can add the following code to AppDelegate.m in order to keep your splash screen displayed during the transition.

  // Place this code after "[self.window makeKeyAndVisible]" and before "return YES;"
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil];
UIViewController *vc = [sb instantiateInitialViewController];
rootView.loadingView = vc.view;

每次以物理设备为目标时都会构建静态打包包,即使在调试中也是如此。如果你想节省时间,请通过将以下内容添加到 Xcode 构建阶段 Bundle React Native code and images 中的 shell 脚本来关闭调试中的包生成:

¥The static bundle is built every time you target a physical device, even in Debug. If you want to save time, turn off bundle generation in Debug by adding the following to your shell script in the Xcode Build Phase Bundle React Native code and images:

 if [ "${CONFIGURATION}" == "Debug" ]; then
export SKIP_BUNDLING=true
fi

2. 构建要发布的应用

¥ Build app for release

现在,你可以通过点击 Cmd ⌘ + B 或从菜单栏中选择“产品”→“构建”来构建要发布的应用。一旦构建用于发布,你将能够将应用分发给 Beta 测试人员并将应用提交到 App Store。

¥You can now build your app for release by tapping Cmd ⌘ + B or selecting ProductBuild from the menu bar. Once built for release, you'll be able to distribute the app to beta testers and submit the app to the App Store.

信息

你还可以使用 React Native CLI 来执行此操作,使用选项 --mode 和值 Release(例如,从项目的根目录:npm run ios -- --mode="Release"yarn ios --mode Release)。

¥You can also use the React Native CLI to perform this operation using the option --mode with the value Release (e.g. from the root of your project: npm run ios -- --mode="Release" or yarn ios --mode Release).

完成测试并准备发布到 App Store 后,请按照本指南进行操作。

¥Once you are done with the testing and ready to publish to App Store, follow along with this guide.

  • 启动你的终端,导航到应用的 iOS 文件夹并输入 open .

    ¥Launch your terminal, and navigate into the iOS folder of your app and type open ..

  • 双击 YOUR_APP_NAME.xcworkspace。它应该启动 XCode。

    ¥Double click on YOUR_APP_NAME.xcworkspace. It should launch XCode.

  • 单击 ProductArchive。确保将设备设置为 "任何 iOS 设备 (arm64)"。

    ¥Click on ProductArchive. Make sure to set the device to "Any iOS Device (arm64)".

注意

检查你的打包包标识符,并确保它与你在 Apple 开发者仪表板的标识符中创建的标识符完全相同。

¥Check your Bundle Identifier and make sure it is exactly same as the one you have created in the Identifiers in Apple Developer Dashboard.

  • 归档完成后,在归档窗口中,点击 Distribute App

    ¥After the archive is completed, in the archive window, click on Distribute App.

  • 现在点击 App Store Connect(如果你想在 App Store 中发布)。

    ¥Click on App Store Connect now (if you want to publish in App Store).

  • 单击 Upload → 确保选中所有复选框,然后单击 Next

    ¥Click Upload → Make sure all the check boxes are selected, hit Next.

  • 根据你的需要在 Automatically manage signingManually manage signing 之间进行选择。

    ¥Choose between Automatically manage signing and Manually manage signing based on your needs.

  • 单击 Upload

    ¥Click on Upload.

  • 现在你可以在 App Store Connect 的 TestFlight 下找到它。

    ¥Now you can find it in the App Store Connect under TestFlight.

现在填写必要的信息,然后在“构建”部分中选择应用的构建,然后单击 SaveSubmit For Review

¥Now fill up the necessary information and in the Build Section, select the build of the app and click on SaveSubmit For Review.