简体   繁体   English

Cordova:如何使用cordova-cli为每个平台设置不同的包名?

[英]Cordova: How to set different package names per platform using the cordova-cli?

I have an app for iOS and Android that I am upgrading from PhoneGap 2.x to Cordova 4.0. 我有一个适用于iOS和Android的应用程序,我正在从PhoneGap 2.x升级到Cordova 4.0。

As the iOS and Android apps were created using PhoneGap 2.x I have two separate projects (ie a project for iOS and a project for Android). 由于iOS和Android应用程序是使用PhoneGap 2.x创建的,我有两个独立的项目(即iOS项目和Android项目)。 These projects have a shared www directory (using symbolic links) for the HTML/CSS/JavaScript assets. 这些项目具有HTML / CSS / JavaScript资产的共享www目录(使用符号链接)。 When I upgrade to Cordova 4.0 I can have a single Cordova project and use the Cordova CLI to create projects for each platform in the platforms directory. 当我升级到Cordova 4.0时,我可以拥有一个Cordova项目,并使用Cordova CLI为platforms目录中的每个平台创建项目。

The package name that is used to for each platform in Cordova is set in shared a config.xml file though. 用于Cordova中每个平台的包名称是在共享的config.xml文件中设置的。 The Cordova CLI uses the package name set in the config.xml for the perpare, build and add platform commands. Cordova CLI使用config.xml中设置的包名称来执行perpare,build和add platform命令。

Unfortunately the package names that were used for the PhoneGap 2.x apps are not the same (ie the package name for the Android app is different to the package name of the iOS app). 不幸的是,用于PhoneGap 2.x应用程序的软件包名称并不相同(即Android应用程序的软件包名称与iOS应用程序的软件包名称不同)。

For example: the Android app has a package name like com.example.applongname but the iOS app has a package name like com.example.AppShortName. 例如:Android应用程序的包名称为com.example.applongname,但iOS应用程序的包名称为com.example.AppShortName。 The beginning of the package name (ie reverse company domain name) is the same for each app but the application names differ. 包名称的开头(即反向公司域名)对于每个应用程序都是相同的,但应用程序名称不同。 The iOS application name also contains capital letters. iOS应用程序名称还包含大写字母。

I need to keep the package names that were used for the initial PhoneGap 2.x builds so that the apps can be updated (ie the end users can receive an update that will replace their existing install of my app). 我需要保留用于初始PhoneGap 2.x版本的软件包名称,以便可以更新应用程序(即最终用户可以接收更新,以替换他们现有的应用程序安装)。

How I can set the package name per platform without creating two separate projects? 如何在不创建两个单独项目的情况下为每个平台设置包名?

Write widget this way: 以这种方式写小部件:

<widget id="com.company.app" android-packageName="com.company.androidapp" ios-CFBundleIdentifier="com.company.iosapp" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">

see my other answer for more details. 有关详细信息,请参阅我的其他答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM