配置APP名称的正确位置在哪里?

时间:2020-05-25 11:36:57

标签: ionic-framework ionic4 capacitor

每个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",
  ...
}

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

预先感谢

2 个答案:

答案 0 :(得分:2)

电容器可用于任何框架,而不仅适用于Ionic,因此应用程序名称应位于capacitor.config.json中。

但是正如您所说的,Capacitor接受“一次编写代码,到处配置”的想法,因此appName仅在添加ios或android平台时使用,添加后必须更改的名称来自iOS应用程序的Xcode或Android应用程序的Android Studio。

答案 1 :(得分:0)

使用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/