在哪里配置APP名称合适?

Where is the right place to configure the APP name?

每个 Ionic 项目都有一个项目配置文件ionic.config.json,您可以在其中配置应用程序的人类可读名称:

{
  // The human-readable name of the app.
  "name": "My App",

  // The project type of the app. The CLI uses this value to determine which
  // commands and command options are available, what to output for help
  // documentation, and what to use for web asset builds and the dev server.
  "type": "angular",

  // The App ID for Ionic Appflow.
  "id": "abc123",

  // Configuration object for integrations such as Cordova and Capacitor.
  "integrations": {
    "cordova": {
      ...
    }
  },

  // Hook configuration--see the Hooks section below for details.
  "hooks": {
    ...
  }
}

使用capacitor给了我们另一个放置应用名称的机会:

{
  // The package name for Android and the bundle identifier for iOS.
  "appId": "com.company.appname",

  // Your app's name.
  "appName": "Capacitor Kitchen Sink",

  // Sets the directory of your built web assets. This is the directory that will be
  // used to run your app in a native environment.
  "webDir": "www",

  // The JavaScript package manager to use, either npm or yarn.
  "npmClient": "npm",
  ...
}

应用名称的正确位置在哪里?

提前致谢

使用 Cordova 的 config.xml。为此,您有标签 <name>MyAppName</name>。这是最终会出现在图标下的名字。

<widget id="com.mycompany.myapppackage" version="0.0.1" versionCode="1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>My App's name</name>
    <description>A nice description of my app.</description>
    <author email="mymail@myserver.com" href="https://www.myserver.com">Author's name</author>
    ...
</widget>

更多信息:https://cordova.apache.org/docs/en/latest/config_ref/

Capacitor 适用于任何框架,而不仅仅是 Ionic,因此应用程序名称应位于 capacitor.config.json.

但是正如您所说,Capacitor 包含了 "Code once, configure everywhere" 的想法,因此 appName 仅在您添加 ios 或 android 平台时使用,一旦您添加了它们后,您必须将名称从 Xcode 更改为 iOS 应用程序或从 Android Studio 更改为 Android 应用程序。