使用 JavaScript 构建本机应用程序的最佳方式? [英] Best way to build native applications with JavaScript?

查看:14
本文介绍了使用 JavaScript 构建本机应用程序的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我玩phonegap已经有一段时间了,在我的 Android 上做了一些测试...

I've been playing for a while with phonegap, did some tests on my Android...

还不错.

我的问题是:
使用 Web 客户端(HTML/JavaScript/CSS)开发原生移动应用程序的最佳(您最喜欢的)框架是什么?

My questions are:
What is the best (your favorite) framework to develop native mobile applications with web client side (HTML / JavaScript / CSS)?

在多平台(iOS/Android/BlackBerry)并行构建和维护这些应用程序有多容易?不同平台(iOS/Android/黑莓)之间有很多例外吗?

How easy is to build and maintain those applications in multiplatforms (iOS / Android / BlackBerry) parallel? Does it has many exceptions between different platforms (iOS / Android / BlackBerry)?

开发适用于 iOS 的应用程序有哪些要求?我是否需要一个带有特殊 SDK 的特殊 IDE?我必须有 Mac 吗?

What are the requirements to develop my app for iOS? Should I need a special IDE with special SDK? Must I have a Mac?

推荐答案

我们目前正在使用 React Native.如果不包括在这里,那就太可惜了.

We're currently building a native iOS application using React Native. It would be a shame if it wasn't included here.

优点:

  • React 将 DOM 视为实现细节.这使得向原生 UI 的过渡非常自然.在编写本机应用程序时,它还消除了对 HTML/CSS 的需要.您只需要使用 JavaScript 编写的本机组件.
  • 原生组件!基本的本机组件已经桥接到 JavaScript,并且有一个社区正忙于将其他所有组件都带过来.问题是,如果你知道或愿意学习一些 Objective C 或 Java,有一个 简单的过程 将任何本机模块(或第三方模块)添加到 React Native.
  • 快速迭代.自 3 月份开源以来,已向 master 分支提交了 2600 多次提交.
  • 您可以获得普通 React 的所有优势:虚拟视图层、差异化、声明式 UI 创建、出色的开发者体验和一流的社区.
  • 您可以从同一个代码库为多个平台构建,重用大部分相同的代码库(主要是应用逻辑).
  • React treats the DOM as an implementation detail. This made the transition over to native UI very natural. It also removes the need for HTML/CSS when writing a native app. All you need is native components, written in JavaScript.
  • Native components! The fundamental native components have already been bridged over to JavaScript, and there is a community busy at work bringing everything else over. The thing is, if you know or are willing to learn some Objective C or Java, there is an easy process to add any native module (or third-party module) to React Native.
  • Quick iteration. There have been over 2600 commits to the master branch since it was open-sourced in March.
  • You get all of the benefits of normal React: a virtual view layer, diffing, declarative UI creation, fantastic developer experience, and a stellar community.
  • You can build for multiple platforms from the same repository, reusing much of the same codebase (application logic, mostly).

缺点:

  • 还年轻.有一些功能需要 jimmy-rigging、第三方库或自定义 Objective-C/Java 才能工作.
  • 一些与 DOM 或浏览器 API 相关联的优秀第三方库仍然无法在 React Native 上运行,包括 React Router.
  • 最大的痛苦与 XCode 和 Apple 的开发者计划有关,但没有办法绕过它.

在多平台中构建和维护这些应用程序有多容易?

React Native for Android 于 2015 年 9 月 14 日开源.我还没有使用它,但这是我目前能够学到的东西.2016 年 10 月 21 日更新: 今年早些时候宣布了适用于 Windows 通用平台的 React Native.这意味着您现在可以使用 React Native 为 Windows 桌面、Windows 手机甚至 Xbox 构建应用程序!

React Native for Android was open-sourced on September 14th, 2015. I haven't used it yet, but here's what I've been able to learn so far. Update 10/21/16: React Native for the Windows Universal Platform was announced earlier this year. That means you can now use React Native to build apps for Windows desktop, Windows phones, and even Xbox!

React Native 不是旨在成为一次编写,随处运行的心态.他们采用了一次学习,随处编写的范式.iOS 是一个与 Android 截然不同的平台,因此需要为任一平台的设计付出真诚的努力.原生 API 也会有所不同.

React Native is not intended to be a write once, run anywhere mentality. They adopt a learn once, write anywhere paradigm instead. iOS is a very different platform than Android, so sincere effort needs to be put into the design for either platform. The native APIs will also be different.

因此,您最终会为原生组件和 API 重写代码.但是,您的大部分应用程序逻辑都可以重用.事实上,React-Native 是经过组织的,因此您可以将 Android 和 iOS 应用程序保存在同一个存储库中,以便您可以在可能的情况下重用相同的代码.我认为这很棒,但只有时间会证明一切.据他们说,到目前为止效果很好.

So, you will end up re-writing code for native components and APIs. However, much of your application logic can be re-used. In fact, React-Native is organized so that you can keep both your Android and iOS applications in the same repository, so that you can re-use the same code when possible. I think it's brilliant, but only time will tell. According to them, it works well so far.

顺便说一下,Facebook 的一个团队使用 React Native 构建了一个 iOS 应用,然后转向围绕并在三个月内使用 87% 的相同代码库构建了 Android 版本.

By the way, a team at Facebook built an iOS app using React Native, then turned around and built the Android version in three months using 87% of the same code base.

开发适用于 iOS 的应用程序有哪些要求?

目前,您需要 Mac 和 XCode 才能部署.目前解决这个问题的方法很少.根据 this issue 和 Slack 上的对话,一旦部署,您就可以实际开发从 Windows 或 Linux 机器.Facebook 还致力于开源他们所有的 Nuclide 软件包,根据 他们在 F8 上的演示,将包括无需 XCode 即可打包和构建的工具.

Currently, you need a Mac and XCode in order to deploy. Currently there are very few ways around this. According to this issue and from conversations on Slack, once deployed, you can actually develop from a Windows or Linux machine. Facebook is also working on open-sourcing all of their Nuclide packages, which, according to their presentation at F8, will include tools to package and build without XCode.

总的来说,React Native 是一次出色的体验.在我看来,这是目前最重要的.社区内的感觉也非常积极.我只能假设随着时间的推移它会变得更好.

Overall, React Native has been a stellar experience. It is, in my opinion, head and shoulders above anything else currently out there. The feeling within the community is also very positive. I can only assume it will get better with time.

这篇关于使用 JavaScript 构建本机应用程序的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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