NativeScript

本页使用了标题或全文手工转换
维基百科,自由的百科全书
NativeScript
原作者Telerik by Progress.[1]
开发者社群
首次发布2014年 (2014)
当前版本
  • 7.0.0 (2020年9月3日)[2]
编辑维基数据链接
源代码库 编辑维基数据链接
编程语言JavaScriptTypeScript
平台跨平台
许可协议Apache License 2.0
网站nativescript.org

NativeScript是一个提供开发Apple iOSAndroid移动应用程序开源软件,最初由Progress构思和开发。[4]2019 年底,Progress的长期合作伙伴nStudio接管NativeScript项目。[5]在nStudio的监督下,NativeScript于2020年12月成为OpenJS基金会的培育项目。[6]NativeScript可以使用JavaScript或是其他可以编译成JavaScript的编程语言编写,例如TypeScript。NativeScript同时也支持Angular[7]Vue[8]。使用NativeScript构建的移动应用程序会产生完整的原生应用程序,其使用了与XcodeAndroid Studio相同API。[9]此外,软件开发人员可以加入CocoaPodsMavennpm.js的第三方程式库到程序中而无须其他的包装函数。[10][11][12]

发展[编辑]

NativeScript于2015年3月首次公开发布,并在两个月后发布了1.0.0版本。[13]NativeScript在公开发布后不久就迅速流行起来,短期之内超过1500名Twitter用户追踪其Twitter,其Github存储库也获得了3000颗以上的星星。[14]与此同时,NativeScript已有700个扩展,分别由Progress官方及开源社区开发。[15][16]除此之外,也可使用Angular来开发在Web平台和移动平台之间共享的应用程序源代码。[17][18]

架构[编辑]

NativeScript和所有必需的扩展都使用包管理器npm安装。用户可通过命令行或名为NativeScript Sidekick的GUI工具建立、配置和编译项目。[19] NativeScript使用XML文件定义不同平台的用户界面,再由XML文件中的抽象描述来调用不同平台的原生UI元素。使用Angular和TypeScript开发的应用程序可以于目标平台外进行开发。NativeScript使用node.js执行和构建移动版应用程序。[20]NativeScript的目标是在iOS和Android两个平台之间实现90%的通用代码。[1]

直接调用原生API及控件[编辑]

NativeScript使用XML文件定义不同平台的用户界面[21],同时NativeScript使用了跨平台的抽象XML资料来触发特定于平台的代码,这些代码直接与目标平台的原生对象交互,例如说当调用NativeScript Button API的UI抽象时,NativeScript会直接调用iOS上的UIButton[22]或Android上的com.android.widget.Button[23]

虽然应用程序可能使用JavaScript、TypeScript、Angular或Vue.js来编写,但其源始码不会被编译或转译,而是按原样直接在设备上执行。此构建方式免除了交叉编译或转译的需求。[12]此外,虽然应用程序的源始码是使用浏览器或包含WebView的移动应用程序中常见的语言编写,但NativeScript应用程序直接在本机设备上执行,而非操作DOM或调用任何浏览器来执行。[7]

主要功能[编辑]

原生API对应[编辑]

NativeScript的另一个特性为使用映射来调用原生API端点。NativeScript不需要在框架和平台API之间单独捆绑,而是使用映射来获取有关原生平台API的信息和元数据,因此可以立即使用所有新加入的API。[7]

用户也可以使用第三方库来达成映射的效果。在NativeScript中JavaScript(或TypeScript/Angular)可以直接与调用原生代码,因此无须使用Objective-C、Swift、Java或Kotlin编写捆绑层(英语:binding layers)。[12][24]

与Angular一同使用[编辑]

自NativeScript 2.0起,开发人员可以使用Angular建置跨平台的项目。[25]除此之外,开发人员使用Angular时可以使用相同的源代码制作网页和移动版应用程序。[26]

与Vue.js一同使用[编辑]

开发人员可以使用nativescript-vue扩展进而在NativeScript使用Vue.js框架。[8]

支持的工具及服务[编辑]

  • NativeScript Sidekick是一个图形用户界面,建构于NativeScript CLI之上。开发人员可以使用NativeScript Sidekick来套用模板、云端构建应用程序,并将应用程序发布到公开的应用程序商店。
  • 开发人员可以使用NativeScript Playground在浏览器中测试NativeScript,并在实体设备上预览应用程序。
  • 开发人员可以在NativeScript市集(英语:NativeScript Marketplace)获取扩展、预构建应用程序模板和可执行的示例应用程序。

参考文献[编辑]

  1. ^ 1.0 1.1 Frequently asked questions about NativeScript. NativeScript.org. [2016-03-20]. (原始内容存档于2016-03-18). 
  2. ^ Release 7.0.0. 2020年9月3日 [2020年12月1日]. 
  3. ^ Releases · NativeScript/NativeScript. GitHub. [2018-06-03]. (原始内容存档于2021-08-31). 
  4. ^ Creating Mobile Native Apps in JavaScript with NativeScript. InfoQ. [2022-07-12]. (原始内容存档于2022-06-19). 
  5. ^ Saripella, Surya. The Next Chapter for NativeScript: nStudio. NativeScript. [2022-07-12]. (原始内容存档于2021-01-16). 
  6. ^ Romoff, Rachel. NativeScript joins OpenJS Foundation as Incubating Project. The Linux Foundation Projects. OpenJS Foundation. 7 December 2020 [4 March 2021]. (原始内容存档于25 January 2021). 
  7. ^ 7.0 7.1 7.2 Krill, Paul. JavaScript goes native for iOS, Android, and Windows Phone apps. InfoWorld. March 10, 2015 [July 12, 2022]. (原始内容存档于January 3, 2022). 
  8. ^ 8.0 8.1 NativeScript-Vue. nativescript-vue.org. [2017-10-31]. (原始内容存档于2021-10-04). 
  9. ^ NativeScript framework eases cross-platform app development woes. searchcloudcomputing.techtarget.com. [2021-08-06]. (原始内容存档于2021-08-06). 
  10. ^ Krill, Paul. NativeScript warms up to AngularJS for mobile dev. InfoWorld. May 6, 2016 [July 12, 2022]. (原始内容存档于June 12, 2022). 
  11. ^ SD Times GitHub Project of the Week: NativeScript. March 18, 2016 [July 12, 2022]. (原始内容存档于March 27, 2022). 
  12. ^ 12.0 12.1 12.2 Telerik's NativeScript Aims To Centralize Cross-Platform Mobile Development -. Visual Studio Magazine. [2016-11-21]. (原始内容存档于2017-11-07). 
  13. ^ NativeScript 1.0.0 Released. www.i-programmer.info. [2022-07-12]. (原始内容存档于2022-06-11). 
  14. ^ NativeScript 1.0.0 is now available. NativeScript.org. [2016-11-04]. (原始内容存档于2016-10-05). 
  15. ^ NativeScript Marketplace. market.nativescript.org. [2018-03-14]. (原始内容存档于2018-03-15). 
  16. ^ nativescript - npm search. www.npmjs.com. [2016-11-21]. (原始内容存档于2017-02-11). 
  17. ^ Review, C. I. O. Progress Releases NativeScript 2.0 with Cross-Platform Deployment Capabilities. CIOReview. [2022-07-12]. (原始内容存档于2022-06-21). 
  18. ^ Getting to Know Angular 2. mobile.htmlgoodies.com. 15 November 2016 [12 July 2022]. (原始内容存档于27 September 2019). 
  19. ^ NativeScript Sidekick - your faithful companion for app development. NativeScript.org. [2017-10-31]. (原始内容存档于2017-11-07) (英语). 
  20. ^ Hanna, Tam. Mit JavaScript wie hausgemacht: NativeScript. Developer. [2022-07-12]. (原始内容存档于2021-07-25). 
  21. ^ The Basics - NativeScript Docs. docs.nativescript.org. [2016-11-21]. (原始内容存档于2016-11-21). 
  22. ^ NativeScript/NativeScript. github.com. [2022-06-20]. (原始内容存档于2022-06-20). 
  23. ^ NativeScript/NativeScript. github.com. [2022-06-20]. (原始内容存档于2022-06-20). 
  24. ^ Accessing Native APIs through JavaScript - NativeScript Docs. docs.nativescript.org. [2016-11-21]. (原始内容存档于2016-11-24). 
  25. ^ NativeScript 2.0 - the best way to build cross-platform native mobile apps. NativeScript.org. [2016-11-21]. (原始内容存档于2016-12-20). 
  26. ^ Witalec, Sebastian. Apps That Work Natively on the Web and Mobile. Medium. 2018-08-24 [2021-08-06]. (原始内容存档于2022-01-03) (英语). 

外部链接[编辑]