如何使用 Phonegap 命令行工具为 iOS 发布 Build?

Posted

技术标签:

【中文标题】如何使用 Phonegap 命令行工具为 iOS 发布 Build?【英文标题】:How to make release Build for iOS using Phonegap Command Line Tools ? 【发布时间】:2013-10-28 07:13:13 【问题描述】:

我想使用分发证书移动配置文件iOS平台制作Release Build。我想在不想打开 XCode 的地方使用 Phonegap(Cordova) 命令行工具

我有移动配置文件和分发证书。我还在我的机器上安装了 XCodeNodeJS,但我不想打开 Xcode,只使用 cordova 命令行工具生成 ios 版本。

如果可能,请帮助我。

【问题讨论】:

PhoneGap how to make a release build from the command-line的可能重复 @Nirk :上述问题没有描述如何向应用程序添加分发证书和移动配置。 从 xcode 中执行。它会让你的生活更轻松。 【参考方案1】:
cordova build ios --device --release

您应该在cordova 中有一个名为build.json 的文件。 在 build.json 中,内容应该是这样的

  "ios": 
    "debug": 
       "codeSignIdentitiy": "iPhone Development",
       "provisioningProfile": "*****"
    ,
   "release": 
     "codeSignIdentitiy": "iPhone Distribution",
     "provisioningProfile": "******"
   
 

【讨论】:

我花了一段时间才发现,解决方案中的 provisioningProfile 星号必须替换为 mobileprovision 文件 UUID,而不是 mobileprovision 文件名本身。但现在可以了。 我应该把 build.json 放在哪里?只是在根?在 ios 文件夹中? @Diceble 是的,根。 "codeSignIdentitiy" ?是不是有错别字,因为“codeSignIdentity”(最后没有多余的 i)似乎更合乎逻辑。【参考方案2】:

我知道这是一个旧线程,但我遇到了同样的问题,我的回答可能会帮助更多人。

在您的 cordova/phonegap 项目中,您可以写入 build.xcconfig 以满足您的所有配置需求。该文件位于此处:<project-dir>/platforms/ios/cordova/build.xcconfig

当您使用可选的--release--device 运行cordova build ios 时,cordova 将指向该文件。这允许通过对cordova的最小修改进行简单的配置。

【讨论】:

【参考方案3】:

快跑

<project_dir>/platforms/ios/cordova/build.sh --release

这个platforms/<platform>/cordova 目录包含实际的构建脚本。您可以查看它以了解 cordova 是如何构建的。

UPD。 要使设备构建(即使用 arm 架构,不适用于 i386 模拟器)也传递 --device 参数。

【讨论】:

【参考方案4】:

您应该继续在 build.phonegap.com 上创建一个包含电子邮件和密码的帐户。 登录后,有以下步骤:

1. Upload a zip of your project.
2. Start building it for first time.
3. Go on account (top left user icon) -> edit settings
4. Go to on Signing keys and add a new key by uploading the p12 and provisioning files
5. Unlock it using the password of the certificate.
6. Go on apps menu, you should have the app.
7. Press on app title in order to expand the builds
9. Select the key for IOS.

After that start a cmd window, make sure you have all requirements met (as is described here:http://docs.phonegap.com/en/3.0.0/guide_cli_index.md.html).
In that cmd window, you should perform following commands:
phonegap remote login -u <the account email> -p <the password>
phonegap remote build ios


In order to be all ok, you should be sure to have in config.json file the id of this new account.
Also, in order to perform the previous phonegap commands, you need to be in the folder of the project.

Please, be aware, the activation of the ios key is around 1 hour. If you want to do this automatically, you should first login, unlock the key, and build.

【讨论】:

这篇文章没有回答这个问题。问题是关于使用命令行工具为 IOS 构建版本。不是在线构建服务。

以上是关于如何使用 Phonegap 命令行工具为 iOS 发布 Build?的主要内容,如果未能解决你的问题,请参考以下文章

如何使用cordova命令行创建好一个工程

iOS 常用命令行工具使用方法

是否可以从命令行拆卸和重新组装 iOS IPA 文件?

如何在自定义地图上进行离线地理定位,phonegap+kml

phonegap 3.4、3.3 命令行界面会发生啥?

适用于 iOS 的 Phonegap/Cordova 日历插件无响应