Cordova 快速入门记录

时间:2022-12-28 20:31:24

本篇文章由:http://xinpure.com/cordova-quick-start-recording/

记一笔

Cordova 官网入门文档 Get Started Fast,言简意该、通俗易懂。

在此仅记录过程及安装时遇到的问题,做个纪念什么的也好。

开始使用

完全就是根据官方文档,敲敲命令而已

安装 Cordova

xinpureZhu:cordova xinpure$ sudo npm install -g cordova

创建项目

xinpureZhu:cordova xinpure$ cordova create MyApp

Creating a new cordova project.

添加平台支持

Cordova 现支持的平台 amazon-fireos, android, blackberry10, browser, firefoxos, ios, osx, webos

这里便随着文档,选择了 browser

xinpureZhu:cordova xinpure$ cd MyApp/

xinpureZhu:MyApp xinpure$ ls

config.xml  hooks       platforms   plugins     www

xinpureZhu:MyApp xinpure$ cordova platform

Installed platforms:

Available platforms: amazon-fireos, android, blackberry10, browser, firefoxos, ios, osx, webos

xinpureZhu:MyApp xinpure$ cordova platform add browser

Adding browser project...

Creating Browser project. Path: platforms/browser

Discovered plugin "cordova-plugin-whitelist" in config.xml. Installing to the project

Fetching plugin "cordova-plugin-whitelist@1" via npm

Installing "cordova-plugin-whitelist" for browser

启动 App

xinpureZhu:MyApp xinpure$ cordova run browser

Running command: /Project/cordova/MyApp/platforms/browser/cordova/run

Static file server running on port 8000 (i.e. http://localhost:8000)

CTRL + C to shut down

Static file server running @ http://localhost:8000/index.html

CTRL + C to shut down

Executing command: open -n -a "Google Chrome" --args --user-data-dir=/tmp/temp_chrome_user_data_dir_for_cordova http://localhost:8000/index.html

到此,Cordova 快速入门便结束了,确实比较简单的

为项目添加 ios 平台支持

WebApp 当然还是要在手机上跑起来才到位,这里使用 ios 尝尝鲜

为项目添加ios平台

xinpureZhu:MyApp xinpure$ cordova platform add ios

Adding ios project...

iOS project created with cordova-ios@3.9.1

Installing "cordova-plugin-whitelist" for ios

以新平台启动App

xinpureZhu:MyApp xinpure$ cordova run ios

Running command: /Project/cordova/MyApp/platforms/ios/cordova/run

ios-sim was not found. Please download, build and install version 3.0.0 or greater from https://github.com/phonegap/ios-sim into your path, or do 'npm install -g ios-sim'

ERROR running one or more of the platforms: Error: /Project/cordova/MyApp/platforms/ios/cordova/run: Command failed with exit code 2

You may not have the required environment or OS to run this project

执行命令终于不是那么顺畅了,缺少 ios-sim 模块 (解决方法已清楚的提示,所以也不算是问题啦)

按提示执行命令:

xinpureZhu:MyApp xinpure$ sudo npm install -g ios-sim

安装完成后再重新执行启动命令:

xinpureZhu:MyApp xinpure$ cordova run ios

Running command: /Project/cordova/MyApp/platforms/ios/cordova/run

simctl was not found.

Check that you have Xcode 6.x installed:

    xcodebuild --versionCheck that you have Xcode 6.x selected:
xcode-select --print-path ERROR running one or more of the platforms: Error: /Project/cordova/MyApp/platforms/ios/cordova/run: Command failed with exit code 2 You may not have the required environment or OS to run this project

好吧,看到这个错误提示,我的内心是茫然的。

我使用的是 Mac OS X EI Capitan, Xcode 也更新到了 7.0.1, 何故如此?

再次 查看文档后发现不同于 bowser 平台,ios平台需要先 build

其实之前也看到过 build 这一操作,但是思维定势,想当然的以为 cordova run 会同时执行 cordova build,然而并不是。

Build App

xinpureZhu:MyApp xinpure$ cordova platform ls

Installed platforms: browser 4.0.0, ios 3.9.1

Available platforms: amazon-fireos, android, blackberry10, firefoxos, osx, webos

xinpureZhu:MyApp xinpure$ cordova build ios

...此处省略一连串 Build 信息..

** BUILD SUCCEEDED **

出现了 SUCCEEDED 显然已经成功了

使用仿真器启动 App

xinpureZhu:MyApp xinpure$ cordova emulate ios

此处依然省略大量, 启动时的编译信息。启动成功也会 SUCCEEDED 提示,同时 Xcode 仿真器也会启动并打开 App

总结

虽然官方已经提供了详细的说明文档,文档也简单易懂,但是不管多简单还是要亲自动手敲敲命令,说不定就会出现一些意想不到的问题。

Cordova 快速入门记录的更多相关文章

  1. SpringMVC快速入门记录(一)

    1.SpringMVC入门:表现层框架,spring的一部分 2.Spring处理流程: 3.要在web.xml里写好相关配置 <!--配置DispatcherServlet--> &lt ...

  2. gRPC快速入门记录

    为什么使用grpc 1.protocl buffer一种高效的序列化结构. 2.支持http 2.0标准化协议. http/2 1.http/2对每个源只需创建一个持久连接,在这一个连接内,可以并行的 ...

  3. SpringMVC快速入门记录(二)

    一.数组参数绑定和List参数绑定 1.数组参数绑定 提交多个相同name的参数,保持name的名字和Controller方法参数的数组名称相同即可. 2.List参数绑定 List中存放对象,并将定 ...

  4. SignalR快速入门 ~ 仿QQ即时聊天,消息推送,单聊,群聊,多群公聊(基础&equals;》提升)

     SignalR快速入门 ~ 仿QQ即时聊天,消息推送,单聊,群聊,多群公聊(基础=>提升,5个Demo贯彻全篇,感兴趣的玩才是真的学) 官方demo:http://www.asp.net/si ...

  5. 【番外篇】ASP&period;NET MVC快速入门之免费jQuery控件库(MVC5&plus;EF6)

    目录 [第一篇]ASP.NET MVC快速入门之数据库操作(MVC5+EF6) [第二篇]ASP.NET MVC快速入门之数据注解(MVC5+EF6) [第三篇]ASP.NET MVC快速入门之安全策 ...

  6. Mybatis框架 的快速入门

    MyBatis 简介 什么是 MyBatis? MyBatis 是支持普通 SQL 查询,存储过程和高级映射的优秀持久层框架.MyBatis 消除 了几乎所有的 JDBC 代码和参数的手工设置以及结果 ...

  7. 【第四篇】ASP&period;NET MVC快速入门之完整示例(MVC5&plus;EF6)

    目录 [第一篇]ASP.NET MVC快速入门之数据库操作(MVC5+EF6) [第二篇]ASP.NET MVC快速入门之数据注解(MVC5+EF6) [第三篇]ASP.NET MVC快速入门之安全策 ...

  8. spring快速入门(二)

    一.在spring快速入门(一)的基础上,我们来了解spring是如何解决对象的创建以及对象之间的依赖关系的问题 (比如client中依赖UserAction的具体实现,UserActionImpl中 ...

  9. OpenStack云计算快速入门之一:OpenStack及其构成简介

    原文:http://blog.chinaunix.net/uid-22414998-id-3263551.html OpenStack云计算快速入门(1) 该教程基于Ubuntu12.04版,它将帮助 ...

随机推荐

  1. TinyFrame系列:基于EFCodeFirst&comma;IOC&comma;AOP的轻型框架

    TinyFrame开篇:基于CodeFirst的ORM TinyFrame续篇:整合Spring IOC实现依赖注入 TinyFrame再续篇:整合Spring AOP实现日志拦截 TinyFrame ...

  2. Maven相关: An internal error occurred during&colon; &quot&semi;Updating Maven Project&quot&semi;&period; java&period;lang&period;NullPointerException

    I solved mine by delete the .settings folder and .project file in the project and then reimport the ...

  3. web请求报出 &OpenCurlyDoubleQuote;超过了最大请求长度” 【注意:重启IIS】

    摘自:http://www.cnblogs.com/loalongblogs/archive/2012/10/16/2726372.html web请求报出 “超过了最大请求长度”   错误原因:as ...

  4. iOS UICollectionView基础

    转载自:http://www.cnblogs.com/wayne23/p/4013522.html  初始化部分: UICollectionViewFlowLayout *flowLayout= [[ ...

  5. 基于C&num;的Appium自动化测试框架&lpar;Ⅰ&rpar;

    因为工作原因,使用的编程语言都是C#,但是国内相应的Appium资料少得可怜,Java版本的Appium也考虑过,但是奈何自己搞不定Eclipse这个编译环境[说白了就是因为懒-- 无意中看到了外面的 ...

  6. java&period;util&period;concurrent&period;TimeoutException&colon; Idle timeout expired&colon; 300000&sol;300000 ms

    Request idle timed out at 123000 ms. That means there was no activity (read or write) for 123000 ms ...

  7. CUDA编程之快速入门

    CUDA(Compute Unified Device Architecture)的中文全称为计算统一设备架构.做图像视觉领域的同学多多少少都会接触到CUDA,毕竟要做性能速度优化,CUDA是个很重要 ...

  8. linux VIM 下的语法高亮及自动缩进

    显示行号 set number 自动缩进有两个选项 set autoindent set cindent autoindent 就是自动缩进的意思,当你在输入状态用回车键插入一个新行,或者在 norm ...

  9. Python pip 常用命令

    使用了这么就pip命令,但是一直是简单使用,很多命令都是用了查,查了用,今天把常用的命令汇总一下,方便使用. 命令: pip 由上图可以看到 pip 支持一下命令 Commands: install ...

  10. 使用JavaMail发送邮件-no object DCH for MIME type multipart&sol;mixed报错解决

    最近需要实现一个使用Spring schedule按一定时间间隔自动触发条件发送邮件的功能,在开发的过程中,是按照先测试能发出text/html文本邮件,然后测试添加附件发送邮件,我碰到的问题是,文本 ...