使用开发版本

了解如何使用项目的开发版本。


通常,从头创建一个新的原生构建需要很长时间,以至于你可能会想切换任务,从而失去专注。然而,如果你的设备或模拟器/模拟器上安装了开发构建版本,你就无需等待原生构建过程,直到你更改应用的底层原生代码

🌐 Usually, creating a new native build from scratch takes long enough that you'll be tempted to switch tasks and lose your focus. However, with the development build installed on your device or an emulator/simulator, you won't have to wait for the native build process until you change the underlying native code that powers your app.

启动开发服务器

🌐 Start the development server

要开始开发,请运行以下命令来启动开发服务器:

🌐 To start developing, run the following command to start the development server:

Terminal
npx expo start

要在开发客户端中打开项目:

🌐 To open the project inside your development client:

  • ai 键,在 Android 模拟器或 iOS 模拟器上打开你的项目。
  • 在物理设备上,通过系统摄像头或 QR 码阅读器扫描 QR 码,以在设备上打开项目。

启动器屏幕

🌐 The launcher screen

如果你从设备的主屏幕启动开发版本,你将看到启动器屏幕,如下所示:

🌐 If you launch the development build from your device's Home screen, you will see your launcher screen, which looks similar to the following:

如果在你的本地网络上检测到打包器,或者你在 Expo CLI 和你的开发构建中都已登录了 Expo 账户,你可以直接从此屏幕连接到它。否则,你可以通过扫描 Expo CLI 显示的二维码进行连接。

🌐 If a bundler is detected on your local network, or if you have signed in to an Expo account in both Expo CLI and your development build, you can connect to it directly from this screen. Otherwise, you can connect by scanning the QR code displayed by the Expo CLI.

重建开发版本

🌐 Rebuild a development build

如果你向项目中添加一个包含本地代码 API 的库,例如 expo-secure-store,你将需要重新构建开发客户端。这是因为当你将库作为项目的依赖安装时,其本地代码不会自动包含在开发客户端中。

🌐 If you add a library to your project that contains native code APIs, for example, expo-secure-store, you will have to rebuild the development client. This is because the native code of the library is not included in the development client automatically when installing the library as a dependency on your project.

调试开发版本

🌐 Debug a development build

当需要时,你可以通过在 Expo CLI 中按 Cmd ⌘ + dCtrl + d 来访问菜单,或者摇动你的手机或平板。在这里,你可以访问开发构建的所有功能、所需的调试功能,或者切换到应用的不同版本。

有关更多信息,请参阅调试指南。

🌐 See Debugging guide for more information.