如何在 Windows 10 手机上测试 Ionic 2 应用程序? [英] How do I test Ionic 2 apps on a Windows 10 Mobile Phone?

查看:15
本文介绍了如何在 Windows 10 手机上测试 Ionic 2 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力寻找有意义的 Windows 10 手机测试文档.我已将 win 10 添加为平台并创建了一个项目文件夹,但目前尚不清楚从此时起该做什么.有没有人完成这个过程?

I'm struggling to find meaningful documentation on testing for Windows 10 phone. I've added win 10 as platform and it creates a project folder, but it's not clear what to do from this point on. Has anyone worked through this process?

推荐答案

好的,所以我花了大约 8 个小时完成了它(我认为问题的很大一部分是期望单个站点拥有所需的所有信息(即Ionic 的文档),但最终它需要来自 Ionic、Cordova 和 Microsoft 的信息.无论如何,这是我的笔记:

OK, so I worked through it for about 8 hours (I think a big part of the problem was expecting a single site would have all the information required (i.e. Ionic's docs), but in the end it needed info from Ionic, Cordova and Microsoft. Anyway, here are my notes:

确保您已运行离子平台添加窗口".从platforms/windows文件夹打开windows 10项目(你可以打开解决方案,但如果你打开了,确保win 10项目设置为默认启动).将 cpu 类型设置为 windows-ARM(对于 Lumia 550).

Ensure you've run 'ionic platform add windows'. Open the windows 10 project from the platforms/windows folder (you can open the solution, but if you do, ensure the win 10 project is set as default startup). Set cpu type to windows-ARM (for the Lumia 550).

打开 config.xml(设计器视图)并将任何 API 端点添加到通用​​"选项卡中的域访问"列表中.您可以在此处找到有关 config.xml 的更多信息:Cordova: Config.xml

Open config.xml (designer view) and add any API endpoints to the 'Domain Access' list in the 'Common' tab. You can find out more about the config.xml here: Cordova: Config.xml

在Windows"选项卡下,确保 Windows 10 是目标版本.

Under the 'windows' tab, make sure Windows 10 is the target version.

Win 手机应用需要本地存储的证书才能通过 SSL 访问资源.

Win phone aps require a locally-stored certificate to access resources over SSL.

从服务器下载证书(通过浏览器进行操作,单击挂锁或类似内容并保存为 DER 类型 - 由于某种原因具有 .cer 扩展名).将证书保存到项目根目录,例如'api-certificate.cer'

Download the cert from the server (do it via browser, click on padlock or similar and save as DER type - which has .cer extension for some reason). Save cert to project root e.g. 'api-certificate.cer'

将以下内容添加到 package.windows10..appxmanifest

add the following to package.windows10..appxmanifest

<Extensions>
    <!--Certificates Extension-->
    <Extension Category="windows.certificates">
        <Certificates>
            <Certificate StoreName="Root" Content="api-certificate.cer" />        
        </Certificates>
    </Extension>
</Extensions>

如果需要,可以通过这种方法添加额外的证书(我猜).

If required, additional certs could be added via this method (I guess).

确保在项目中包含 .cer,因为它需要包含在构建的包中.

Ensure to include the .cer in the project, as it will need to be included in the built package.

调试过程可能需要一堆默认情况下未复制到包中的二进制文件.对我来说,它不是复制 SqlLite,它需要复制到调试文件夹和任何芯片架构特定的依赖文件夹,例如 ARM.你会得到显示哪些文件丢失的错误(我什至为它们创建了空文件夹).

The debugging process might require a bunch of binaries that aren't copied into the package by default. For me, it wasn't copying SqlLite, which needs to be copied to the debug folder and any chip-architecture-specific dependency folders such as ARM. You'll get errrors which show which files are missing (I even had empty folders created for them).

在 VS 中构建应用程序(您可以使用 'ionic build windows' 构建,但这对我来说一直失败,因为它尝试构建生成的 windows 项目而不首先设置 cpu 架构).转到项目文件夹>平台>窗口并打开cordovaapp.sln.将 windows 10 项目设置为默认启动并检查它是否设置为 windows-ARM.

Build the app in VS (you can build with 'ionic build windows' but this has been failing for me since it tries to build the generated windows project without setting the cpu architecture first). Go to projectfolder > platforms > windows and open the cordovaapp.sln. Set the windows 10 project to be startup default and check that it's set to windows-ARM.

构建解决方案.

MSDN:打包 UWP 应用

确保 win 10 项目的 appxmanifest 文件包含数据 API 的内容 URI:

Make sure the win 10 project's appxmanifest file contains a content URI for the data API:

https://api.example.com(规则:包含和 WinRT:全部)

https://api.example.com (Rule: include and WinRT: all)

将 api-certificate.cer 文件复制到平台 > windows 文件夹中(或使用 ./reload-platform windows powershell 脚本).

Copy the api-certificate.cer file into the platform > windows folder (or use the ./reload-platform windows powershell script).

转到项目 > 商店 > 创建应用程序包.
为本地包创建选择否"并按照向导进行操作(可能只需要选择正确的架构).API 的 .cer 文件将包含在包中.

Go to project > store > create app package.
Select 'No' for local package creation and follow wizard (prob. only need to choose the right architecture). The .cer file for API will be included in the package.

包将在 AppPackages 文件夹中创建,文件夹名称为 [projectName].[verion].

The package will be created in the AppPackages folder with a [projectName].[verion] folder name.

如果它在连接 USB 的设备上运行,那么它可能可以部署到应用商店.

If it's running on a USB-attached device, then it's probably deployable to the app store.

以下是有用资源的粗略组合:

Here's a rough assemblage of useful resources:

TACO-VS:打包 Windows 应用程序MSDN:侧载还是开发者模式?Technet:Windows 10 中的侧载应用

MSDN:启用侧载

在您要启用的设备上,转到设置".选择更新 &安全性,然后选择对于开发人员.选择您需要的访问级别 - 开发 UWP 应用,选择开发人员模式,否则选择旁加载应用".阅读您选择的设置的免责声明,然后单击是"接受更改.

On your device that you want to enable, go to Settings. Choose Update & security, then choose For developers. Choose the level of access that you need - to develop UWP apps, choose Developer Mode, otherwise choose 'sideload apps'. Read the disclaimer for the setting you chose, then click Yes to accept the change.

可选:使用 winappdeploycmd.exe 进行部署

(MSDN:使用 WinAppDeployCmd.exe 部署 UW 应用程序](https://msdn.microsoft.com/windows/uwp/packaging/install-universal-windows-apps-with-the-winappdeploycmd-tool)

(MSDN: Using WinAppDeployCmd.exe for deploying UW apps](https://msdn.microsoft.com/windows/uwp/packaging/install-universal-windows-apps-with-the-winappdeploycmd-tool)

检查本地可用设备C:"Program Files (x86)""Windows Kits"10inx86winappdeploycmd 设备

Check available devices locally C:"Program Files (x86)""Windows Kits"10inx86winappdeploycmd devices

注意:这个过程 (winappdeploycmd) 可能用处不大,因为我们要么将文件提供给非托管设备客户,要么让他们从应用商店下载它,但它可能代替 Visual Studio 有用.

Note: this process (winappdeploycmd) probably isn't much use, since we'll either give files to unmanaged-device customers or let them download it from app store, but it may be useful in lieu of visual studio.

通过USB将手机连接到PC,然后将新建文件夹中的两个文件复制到手机上(例如下载文件夹):

Connect the phone to PC via USB and copy two files from the newly-built folder on to the phone (e.g. the downloads folder):

示例文件名

CordovaApp.Windows10_0.0.2.0_arm.cerCordovaApp.Windows10_0.0.2.0_arm.appxbundle

CordovaApp.Windows10_0.0.2.0_arm.cer CordovaApp.Windows10_0.0.2.0_arm.appxbundle

在手机上打开文件资源管理器并首先单击 .cer(证书).让它安装.
安装证书允许启用侧载的系统安装包含应用程序的签名 appxbundle.接下来,单击 appxbundle 文件并让它也安装(等待 30 秒,因为它仍在后台安装).注意:除非它出现在最近的项目"列表中,否则不要尝试打开应用程序,否则,由于缺少资产,您会收到一些静默错误,并且屏幕将变为空白或仅返回设备主菜单.

Open File Explorer on the phone and click the .cer (certificate) first. Let it install.
Installing the certificate allows a sideload-enabled system to install signed appxbundles containing the app. Next, click on the appxbundle file and let that install too (wait for 30 secs as it is still installing in background). NOTE: Do not try to open the app unless it has appeared in the 'recent items' list, otherwise you'll get some silent errors due to missing assets and the screen will go blank or just return to device home menu.

一旦出现在应用菜单中,就可以正常加载了.

Once it's appeared in the apps menu, you can load normally.

有了开发者许可,应用可以在提交到应用商店之前进行验证.

With a developer license, apps can be validated before submittal into the app store.

MSDN:验证包

MSDN:使用 Windows 应用认证工具包

这篇关于如何在 Windows 10 手机上测试 Ionic 2 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆